Hello,

Before adding / removing a class (just an example from the top of my head) I always do the following:

Code:
if ( typeof(myelement) != "undefined" && myelement !=  null && typeof(myelement) == 'object' ) {
//add / remove class
}
I feel like this is not a good approach. What are the checks you have to do to make sure an element is in the DOM and can be used for various purposes? Would =='object' be enough?