undefined and null are falsy in javascript but,
var n = null;
if(n===false){
console.log(\'null\');
} else{
console.log(\'has value\');
}
b
You can use not operator(!):
var n = null;
if(!n){ //if n is undefined, null or false
console.log('null');
} else{
console.log('has value');
}
// logs null
It is considered falsy or truthy for Boolean. So if you use like this:
var n = Boolean(null);
if(n===false){
console.log('null');
} else{
console.log('has value');
}
//you'll be logged null