I understand the reasoning behind this. I'm curious about the technical implementation. Having trouble finding this somewhere.
My theory is that as soon as the left NaN is evaluated in any comparison, it automatically returns false without performing the comparison at all. Is this correct?
Yes - if both types are the same, and they are numbers, then if the left one is
NaN, then the result is
false, without checking the value of the right one:
7.2.13 Strict Equality Comparison
The comparison x === y, where x and y are values, produces true or false. Such a comparison is performed as follows:
If Type(x) is different from Type(y), return false.
If Type(x) is Undefined, return true.
If Type(x) is Null, return true.
If Type(x) is Number, then
If x is NaN, return false.
If y is NaN, return false.
If x is the same Number value as y, return true.
If x is +0 and y is ?0, return true.
If x is ?0 and y is +0, return true.