How can I check for an undefined or null variable in JavaScript?
The biggest misconception in many of the answers here is that 'undefined' is a Javascript keyword. It's not a keyword at all, but a variable that (most of the time) happens to be undefined. So the only time "somevar === undefined" works is when the 'undefined' variable really hasn't been defined.
There are 3 undefined in javascript. The global variable undefined, the value undefined and the type undefined. Even if the global variable undefined is overridden, the value undefined still exists. There are several ways to get it one of which is an empty argument to a function, another is a variable declaration without assigning anything: