===
// All of these evaluate to 'true'!
// type coercion automatically
console.log(false == '0');
console.log(null == undefined);
console.log(" \t\r\n" == 0);
console.log('' == 0);
// And these do too!
if ({}) // ...
if ([]) // ...Both
{}and[]are objects, and any object will be coerced to a boolean value oftruein JavaScript.Prefer to use
===and!==to avoid any unintended side-effects of type coercion.
NaN
NaNconsole.log(NaN == NaN); // false
console.log(NaN === NaN); // false
console.log(isNaN(NaN)); // trueLast updated
Was this helpful?