Page 193 - JavaScript
P. 193
false == null // false
false === undefined // false
false === null // false
Using undefined
• If the current scope can't be trusted, use something which evaluates to undefined, for
example void 0;.
• If undefined is shadowed by another value, it's just as bad as shadowing Array or Number.
• Avoid setting something as undefined. If you want to remove a property bar from an Object
foo, delete foo.bar; instead.
• Existence testing identifier foo against undefined could throw a Reference Error, use typeof
foo against "undefined" instead.
NaN Property of the Global Object
NaN ("Not a Number") is a special value defined by the IEEE Standard for Floating-Point Arithmetic,
which is used when a non-numeric value is provided but a number is expected (1 * "two"), or
when a calculation doesn't have a valid number result (Math.sqrt(-1)).
Any equality or relational comparisons with NaN returns false, even comparing it with itself.
Because, NaN is supposed to denote the result of a nonsensical computation, and as such, it isn’t
equal to the result of any other nonsensical computations.
(1 * "two") === NaN //false
NaN === 0; // false
NaN === NaN; // false
Number.NaN === NaN; // false
NaN < 0; // false
NaN > 0; // false
NaN > 0; // false
NaN >= NaN; // false
NaN >= 'two'; // false
Non-equal comparisons will always return true:
NaN !== 0; // true
NaN !== NaN; // true
Checking if a value is NaN
6
You can test a value or expression for NaN by using the function Number.isNaN():
https://riptutorial.com/ 150

