I have a couple of textboxes, Which return javascript Number
values if valid data is in the textboxes, otherwise NaN
. I get this strange behavior.
NaN
is not equal to anything, not even NaN
.
Reference at MDN
More detailed SO question and answer
For the authoritative source, see the ECMAScript 5 Official Specification, sections 11.9.1 and 11.9.3:
1. If Type(x) is the same as Type(y), then
[...]
c. If Type(x) is Number, then
i. If x is NaN, return false.
ii. If y is NaN, return false.
[...]