Thursday, May 21, 2015

When a falsy check against undefined returns a ReferenceError in JavaScript...

...something like this will bubble up to the console...

Uncaught ReferenceError: foo is not defined

 
 

...and something like this is a better way to deal with the falsy check:

if (typeof myThing != "undefined") {
   myThing.useMyMethod(true);
}

 
 

Interesting links to do with the same subject matter:

No comments:

Post a Comment