Pages

Thursday, October 20, 2011

Detecting an undefined object in JavaScript


typeof allows the identifier to never been declared before
if (typeof obj == "undefined")
instead of
if(obj == null) // will throw an error due to never declared


No comments:

Google
 

Java-Struts