undefined and null are falsy in javascript but,
var n = null;
if(n===false){
console.log(\'null\');
} else{
console.log(\'has value\');
}
b
===
checks for identity - the exact same type and value. So null !== false
firstly because they are not the same type, thus will not match when using ===
.
If you just want to check for any falsey value, then check with:
if (!n)
If you want to specifically check for null
, then check for null
like this:
if (n === null)