12729 shaares
316 private links
316 private links
That’s also the reason NaN !== NaN. If NaN behaved like a number and had a value equal to itself, well, you could accidentally do math with it: NaN / NaN would result in 1, and that would mean that a calculation containing a NaN result could ultimately result in an incorrect number rather than an easily-spotted “hey, something went wrong in here” NaN flag.
How to check the value can be used for a calculation?
typeof theValue === "number": to me too, it feels clunky th compare strings in order to use a numberNumber.isNaN()does exactly what it means: it checks for theNaN- but the global function
isNaN()returns true "“if I tried to make you into a number, would that work, or would you end up being NaN?"