๐ขNaN
not a number.
JS โฉ scope โฉ global โฉ global object โฉ property โฉ NaN
( non-configurable, non-writable global object property )โ
a property of the global object. (that is, a variable in global scope).
equivalent to Number.NaN.
NaN is the only value that doesn't equal to itselfโ
// โญ๏ธ `NaN` is the ONLY ONE that doesn't equal to itself.
NaN === NaN, // falseโ๏ธ
NaN !== NaN, // trueโ๏ธ
// equivalent forms
Number.isNaN(x) === (x !== x)trichotomy law๏ผ a < b, a = b, a > b doesn't apply to NaNโ
3 < NaN, // falseโ
3 == NaN, // falseโ
3 > NaN, // falseโisNaN(x)will try to convertxto a number firstโNumber.isNaN(x)never do conversions.
for Number.isNaN(x) to be true, x must be a number firstโ๏ธ
0/0 evaluates to NaN (no error)โ
non-numeric operand(s) in arithmetic operations that cannot convert to numbers convert to NaN.
if either operand is (or converts to) NaN, the result is false.
๐ Infinity
replit๏ผ NaN
Last updated
Was this helpful?