[JavaScript] typeof !== “undefined” vs. != null
https://stackoverflow.com/questions/2703102/typeof-undefined-vs-null up vote 535 down vote accepted typeof allows the identifier to never have been declared before. So it's safer in that regard: if ( typeof neverDeclared == "undefined" ) //no errors if ( neverDeclared == null ) //throws ReferenceError: neverDeclared is not defined