Javascript Data Type check if a defined variable has a value using equality operators
// myvar is undefined var myvar = undefined; if ( myvar === undefined) { console.log("myvar is undefined"); } if ( myvar === null) { console.log("myvar is null"); } // myvar is null var myvar = null; if ( myvar === undefined) { console.log("myvar is undefined"); } if ( myvar === null) { console.log("myvar is null"); } var myvar = null; // check if myvar is null using the bang (!) operator if ( !myvar ) { //from w w w . j a v a 2 s .co m console.log("The variable myvar is null or undefined"); } else { console.log("The variable myvar is not null or undefined"); }