var myVar=null; if(myVar === null){ //I am null; } if (typeof myVar === 'undefined'){ //myVar is undefined }
if( typeof myVar === 'undefined' || myVar === null ){ // myVar is undefined or null }
Undefined used for unintentionally missing values. Null used for intentionally missing values.
// simple check do the job if (myVar) { // comes here either myVar is not null, // or myVar is not undefined, // or myVar is not '' (empty string). }