As @TechnicalChaos said, but here are links to MDN over W3Schools ;)
NaN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN
IsNaN:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isNaN
The pertinent parts being:
It is rather rare to use NaN in a program. It is the returned value
when Math functions fail (Math.sqrt(-1)) or when a function trying to
parse a number fails (parseInt("blabla")).
And:
Unlike all other possible values in JavaScript, it is not possible to
rely on the equality operators (== and ===) to determine whether a
value is NaN or not, because both NaN == NaN and NaN === NaN evaluate
to false. Hence, the necessity of an isNaN function.
Don't think of NaN
along the same lines as null
or undefined
, it's a "special case" :P
But if you're willing to risk it for a biscuit:
NaN.toString() === NaN.toString()
true
But don't do that!