JavaScript variables have inherent Boolean values (typically referred to as "truthy" and "falsy"). Interpreting these values can lead to semantic train wrecks like those in this snippet:
1: console.log("any string" == true); // false 2: console.log("any string" == false); // also false 3: console.log("" == false); // true 4: console.log(null == undefined); // true
5: console.log(NaN == NaN); // false
Let's start with a few ground rules:
-undefined and
null are equal to each other and nothing else.
-NaN does not equal any other value, including itself.
-Comparing two values triggers ...