tl;dr: Guy suggests isNumber(NaN) should be false. But it's true because NaN is part of floating points as defined by IEEE.
My own interpretation? While programmers shouldn't care so much about this particular kind of semantics (instead they should understand the theory behind floats and never have to run into this issue) it might be better just to call NaNs something else, like "undefined number" or something.
> My own interpretation? While programmers shouldn't care so much about this particular kind of semantics (instead they should understand the theory behind floats and never have to run into this issue) it might be better just to call NaNs something else, like "undefined number" or something.
Or, better, call the JavaScript type that represents IEEE-754 Binary64 format -- which includes the union of three sets (finite numbers in a given range, two infinite numbers, and two kinds of Not-a-Number values) something other than "Number".
As dragonwriter has remarked above, the type "Number" includes stuff that isn't a number. That's a bit absurd, it's like having a value "Red" for a "Color" type.
The type should obviously have been called Float or some variant of that, and the type identification function isFloat.
My own interpretation? While programmers shouldn't care so much about this particular kind of semantics (instead they should understand the theory behind floats and never have to run into this issue) it might be better just to call NaNs something else, like "undefined number" or something.