Markdown

[JavaScript] typeof !== “undefined” vs. != null

https://stackoverflow.com/questions/2703102/typeof-undefined-vs-null

up vote535down voteaccepted
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

留言