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

void 0 and undefined is NaN #681

Closed
TripleTre opened this issue Apr 19, 2016 · 3 comments
Closed

void 0 and undefined is NaN #681

TripleTre opened this issue Apr 19, 2016 · 3 comments
Labels

Comments

@TripleTre
Copy link

TripleTre commented Apr 19, 2016

there is nothing wrong with assert.isNaN(void 0) , is this a bug?

@keithamus
Copy link
Member

keithamus commented Apr 19, 2016

Hey @huaguhzheng thanks for the issue

It looks like we use isNaN instead of Number.isNaN - the difference beeing that isNaN ($18.2.3) coerces the value to a number before checking if it is NaN, while Number.isNaN ($20.1.2.4) does not.

We should probably use Number.isNaN - but to do so would be a breaking change. So I welcome a PR to be made, but it should be made against the 4.x.x branch - not master. You'll also need to change the tests which are currently here.

@not-an-aardvark
Copy link
Contributor

not-an-aardvark commented Apr 19, 2016

It looks like this is already fixed on the 4.x.x branch (see #498)

@keithamus
Copy link
Member

Ahhh! Sorry about that, good detective work!

I'll close this. We hope to be releasing 4.0.0 soon enough. For now you can guard the assertion with an additional type check:

var num = void 0;
assert.typeOf(num, 'number');
assert.isNaN(num);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants