In Javascript:
NaN === NaN; // false
I tried to determine when isNaN(foo) not just equivalent to +foo "is" NaN . But I donβt know how to say if something is NaN , except for the use of isNaN , which says yes to many things, none of which === NaN.
So, I think the right way to do this is to circumvent other possibilities:
typeof NaN === 'number'
Therefore I think
typeof(foo) === 'number' && isNaN(foo)
Is closest to what I think. This makes sense because it makes sense that NaN will be the only number that is not a number or something. Is this right and is this the best way?
source share