if( typeof myVar === 'undefined' || myVar === null ){
// myVar is undefined or null
}
if (typeof value !== 'undefined' && value) {
//deal with value'
};
// simple check do the job
if (myString) {
// comes here either myString is not null,
// or myString is not undefined,
// or myString is not '' (empty).
}
if(variable == null) //variable is undefined or null
//check for null or undefined with nullish coalescing operator
let value = null ?? "Oops.. null or undefined";
console.log(value) //Oops.. null or undefined
value = 25 ?? "Oops.. null or undefined";
console.log(value) // 25
value = "" ?? "Oops.. null or undefined";
console.log(value) // ""
var myVar=null;
if(myVar === null){
//I am null;
}
if (typeof myVar === 'undefined'){
//myVar is undefined
}
// 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).
}
if( value ) {
}