prototypejs / prototype

Prototype JavaScript framework
http://prototypejs.org/
Other
3.53k stars 639 forks source link

Object.isNumber returns true on NaN #336

Open BlueEyedRhino opened 6 years ago

BlueEyedRhino commented 6 years ago

Which is extremely funny if you think about it. Interesting it hasn't been noticed until now, but its rather rare situation I suppose. And this project is dead. Unfortunately.

Object.isNumber(NaN) true

ta2edchimp commented 6 years ago

Well, NaN is the value of a variable of type Number, that is "not a number".
It's not that it hasn't been noticed until now (see StackOverflow) — it's according to the specs (JS type Number is an IEEE 754 float.

Think, for example, of parseInt(input) as a function with a return value of type Number and with an input value that cannot be parsed as a numeric value.
The return value must be of type Number, but does not need to be of a numeric value, thus NaN.