how to declare empty variable in javascript code example
Example 1: javascript check for null variables
var myVar=null;
if(myVar === null){
}
if (typeof myVar === '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
if (typeof myVar === 'undefined'){
console.log("I am not defined");
}
var emptyString="";
if (emptyString) {
console.log("im not empty");
}