Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_.isNumber(NaN) === true #1373

Closed
limonte opened this issue Jul 29, 2015 · 6 comments
Closed

_.isNumber(NaN) === true #1373

limonte opened this issue Jul 29, 2015 · 6 comments
Labels

Comments

@limonte
Copy link

limonte commented Jul 29, 2015

Feature or bug?

@megawac
Copy link
Contributor

megawac commented Jul 29, 2015

@jdalton
Copy link
Member

jdalton commented Jul 29, 2015

NaN is of the internal tag Number so _.isNumber returns true.
Just as an invalid date object will still return true for _.isDate.

These methods don't validate the input they just determine if the value is of a specific tag.
You may be looking for _.isFinite.

@jdalton jdalton closed this as completed Jul 29, 2015
@limonte
Copy link
Author

limonte commented Jul 30, 2015

@megawac @jdalton thanks for explanation! Sorry for not-searching before creating the issue :)

@msgoloborodov
Copy link

But it is very unexpectedly. NaN is abbreviation of Not a Number. So isNumber(NotANumber) === true seems crazy.

@ephetic
Copy link

ephetic commented Sep 8, 2017

> typeof NaN
"number"

NaN, Infinity, and 0.22 are all members of the type Number. This isn't even unique to JavaScript. _.isFinite gives you the behavior you want (a Number but not one of those things).

@lock
Copy link

lock bot commented Dec 27, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Dec 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

5 participants