Showing posts with label Interview Questions. Show all posts
Showing posts with label Interview Questions. Show all posts

Monday, April 28, 2014

Undefined vs. Null

Was asked this. Presumed it's JavaScript. Answer here: http://saladwithsteve.com/2008/02/javascript-undefined-vs-null.html
Basically one must keep in mind that an uninitialized variable (var a;) is undefined NOT null.
To be accurate when comparing, i.e. if to determine whether is undefined (unset) or null (set to null) use ===, i.e. if (a===null) or if (a===undefined); don't use (a==null) because that will be true regardless of null or undefined due to type coersion.