-
Notifications
You must be signed in to change notification settings - Fork 558
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
Added "NaN is not NaN" #375
base: master
Are you sure you want to change the base?
Conversation
doc/en/types/equality.md
Outdated
@@ -63,6 +65,17 @@ Here, both operators compare for **identity** and **not** equality; that is, the | |||
will compare for the same **instance** of the object, much like `is` in Python | |||
and pointer comparison in C. | |||
|
|||
### Comparing NaN | |||
If either side of double equals `a == b` contains `NaN`, `false` will be returned. | |||
In case of a tripple equals `a === b`, following things are considered. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo triple
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -63,6 +65,17 @@ Here, both operators compare for **identity** and **not** equality; that is, the | |||
will compare for the same **instance** of the object, much like `is` in Python | |||
and pointer comparison in C. | |||
|
|||
### Comparing NaN |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not quite sure about this explanation, according to my testing and research any equality with NaN, double or triple, returns false.
I would suggest an alternate explanation:
Any equality comparison with `NaN` will return `false`. This includes comparing `NaN` with itself, making it the only value in JavaScript which doesn't equal itself.
I don't think it's relevant here to talk about the type of NaN, although that should probably be added in the typeof
section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've referred to this ecma standards explanation
Great start, but I think currently this isn't thorough enough to be helpful. First - it could explain why |
No description provided.