check is undefined or not

How to check for undefined in JavaScript?

The most popular ways to check variables in js :

if (myVar === undefined)
{...}

and

if (typeof myVar === undefined)
{...}

Happy codding…

Also you can use short version with !! and !!!:

// You can change variables and check results in console
 var imTrue=true; 
 var imFalse=false;
//var imNotIsset=true;

if(!!imNotIsset)
     console.log("imNotIsset is defined and imNotIsset === true");
  else
     console.log("imNotIsset === false or imNotIsset is undefined");

  if(!!imTrue)
     console.log("imTrue is defined and imTrue === true");
  else
     console.log("imTrue === false or imTrue is undefined");

  if(!!!imFalse)
     alert("imFalse is defined and imFalse===false");
  else
     console.log("imFalse === true or imFalse is undefined");