Feature Request: Number.isNumber()

Adrian Sieber adrian.sieber1 at gmail.com
Sun Apr 10 15:08:27 UTC 2016

Hi everybody,

checking if a value is a number is currently really complicated and
I have stumbled upon a fair amount of code where this lead to bugs.

The easiest way is `typeof value === 'number'`.
This however has the drawback that `NaN` also evaluates to true.
Furthermore, basically every expression preceded by a `+` evaluates to true.
… and there are even more gotchas. For a full roundup read

This implementation could also be used as a starting point.
(However, I would argue that `isNumber('3')` should evaluate to false.
It's a string after all.)

Therefore I think a `isNumber` functionality should already be provided
What do you think?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160410/66adfd4a/attachment.html>

More information about the es-discuss mailing list