javascript check if undefined or null or empty code example
Example 1: javascript not null
if (variable !== null) {
console.log("Var is NOT null");
}
Example 2: javascript check if undefined or null
if( typeof myVar === 'undefined' || myVar === null ){
}
Example 3: javascript is not null
if(data !== null && data !== '') {
}
Example 4: javascript check if not null
if (myVar !== null) {...}
if (myVar) {...}
Example 5: javascript check if undefined or null or empty string
if (myString) {
}
Example 6: javascript check if undefined or null
if (myVar) {
}