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

_.isNaN(new Number(NaN)) should return true #749

Closed
jdalton opened this Issue Sep 2, 2012 · 4 comments

Comments

Projects
None yet
5 participants
@jdalton
Contributor

jdalton commented Sep 2, 2012

_.isNaN(new Number(NaN)) should return true because it's handled in _.isEqual(NaN, new Number(NaN)); // => true that way.

@knowtheory

This comment has been minimized.

Collaborator

knowtheory commented Sep 2, 2012

So there is a semantic difference here (potentially).

the question is whether isNaN exists to identify the NaN object, or whether it's intended to identify things that are not valid numbers. new Number(NaN) is indeed not a number, and coerces to NaN, but then so does new Number("taco").

@jdalton

This comment has been minimized.

Contributor

jdalton commented Sep 2, 2012

@knowtheory new Number(NaN) is just the object variation of literal NaN. Since it's detected in _.isEqual it should match. Number("taco") is NaN so new Number("taco") is the object variation of NaN.

@jashkenas jashkenas closed this in 6ebb43f Sep 12, 2012

hokaccha added a commit to hokaccha/underscore that referenced this issue Dec 14, 2012

@davidchambers

This comment has been minimized.

Contributor

davidchambers commented Mar 22, 2015

For what it's worth Number.isNaN behaves differently:

> Number.isNaN(NaN)
true
> Number.isNaN(new Number(NaN))
false
@roy-lau

This comment has been minimized.

roy-lau commented Apr 25, 2018

_.isNaN(new Number(0));
// true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment