undefined in ECMAScript 262
The static value "undefined"
Description
Any variable which has been declared but not assigned a value, or a named property of an object which has not been assigned a value, has the value undefined
.
While undefined
values do compare as equal to the value null
, the two are not the same. To specifically test if a value is undefined
rather than null
, use the typeof
operator:
var foo;
var bar = {};
var someNullValue = null;
foo==null; // ** true
foo==someNullValue; // ** true
typeof(foo); // ** 'undefined'
typeof(someNullValue); // ** 'object'
typeof(bar.jimmyJammy)=='undefined'; // ** true
if (typeof(foo)=='undefined'){
// do something here
}