Feature Request: Number.isNumber()
alex94puchades at gmail.com
Sun Apr 10 16:54:50 UTC 2016
El 10/4/2016 5:08 PM, "Adrian Sieber" <adrian.sieber1 at gmail.com> escribió:
> 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'`.
What about Number.isFinite?
> This however has the drawback that `NaN` also evaluates to true.
Number.isFinite(NaN) is `false`
> Furthermore, basically every expression preceded by a `+` evaluates to
> … 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?
> es-discuss mailing list
> es-discuss at mozilla.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss