NaN === NaN return
> undefined === undefined true > NaN === NaN false > a = NaN NaN > a === a false
On the documentation page I see this:
Testing against NaN
Equality operator (
===) cannot be used to test a value against
Is there any reference that answers to the question? It would be welcome.
Strict answer: Because the JS spec says so:
- If Type(x) is Number, then
- If x is NaN, return false.
- If y is NaN, return false.
Useful answer: The IEEE 754 spec for floating-point numbers (which is used by all languages for floating-point) says that NaNs are never equal.
For an extended discussion, see What is the rationale for all comparisons returning false for IEEE754 NaN values?
Although either side of
NaN===NaN contains the same value and their type is
Number but they are not same. According to ECMA-262, either side of
NaN then it will result false value.
you may find a details rules in here-
©2020 All rights reserved.