xxxxxxxxxx
var myVar=null;
if(myVar === null){
//I am null;
}
if (typeof myVar === 'undefined'){
//myVar is undefined
}
xxxxxxxxxx
let myStr = null;
if (myStr === null) {
console.log("This is a null string!");
}
/*
This will return:
"This is a null string!"
*/
xxxxxxxxxx
let testA = null; //null
//console.log(Object.is(testA, null)); //true //null === null
// This is similar to pythons' isinstanceof(class,variable_to_test)
if(Object.is(testA, null)) {
console.log("This is a Null Value");
}
### Moreover you can also test using the strict equality test (===)
console> testA === null #output: true
let x = null;
if (x === null) {
console.log("x is null");
}
# output: x is null