how to declare empty variable in javascript code example

Example 1: javascript check for null variables

var myVar=null;

if(myVar === null){
    //I am null;
}

if (typeof myVar === 'undefined'){
    //myVar is undefined
}

Example 2: declare empty variable javascript

It's initialized to undefined by default, just use that, you don't have to write it out:

var obj;
If it you want to concatenate to a string, use '', for counters use 0... Just use common sense.

Example 3: javascript check if empty

//check if string is undefined 
if (typeof myVar === 'undefined'){
  console.log("I am not defined");
}

//check if string is empty, null, or 0
var emptyString="";
if (emptyString) {
    console.log("im not empty");
}