Javascript Data Type check difference between null and undefined
var a; // w ww . j a va 2s . c om var b = null; if ( typeof a === 'undefined' ) { console.log( "Variable a is undefined" ); } if ( a === null ) { console.log( "Variable a is null" ); } if ( typeof b === 'undefined' ) { console.log( "Variable b is undefined" ); } if ( b === null ) { console.log( "Variable b is null" ); }