DEV Community

Discussion on: Why NaN === NaN returns false in JavaScript ?!

Collapse
 
jessekphillips profile image
Jesse Phillips • Edited

It is because the floating point standard requires it en.m.wikipedia.org/wiki/IEEE_754

And as Alex Lohr points out this is very important in mathematics because

var a = 6 + 9;
var b = average() - 3;

if(a  < b)...
Enter fullscreen mode Exit fullscreen mode

If average() is NAN, b is NAN, the condition is false. Now that does not mean an else clause can assume a >= b because that is also false. But this ensures we don't try average() == mean() and go down a path where clearly we don't know.