Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Wrong value for _.isEqual(0, new Number(Number.MIN_VALUE)) #2815
base: master
Are you sure you want to change the base?
Wrong value for _.isEqual(0, new Number(Number.MIN_VALUE)) #2815
Changes from all commits
f64b8e8
b305986
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
This just collapses the entire expression to
+a === +b
, since to enter the first branch, both+a
and+b
must already have been found to exactly equal0
. You can preserve the original fuzziness and still make the comparison symmetric by using a disjunction instead of a conjunction:It may actually be worth considering to also allow fuzziness when both values are close to zero but neither is exactly zero. This seems more consistent as it doesn't treat zero as a special case:
However, maybe there is something to say for making the comparison symmetrically exact instead of symmetrically fuzzy:
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.
Actually this is not fully equivalent. The initial check distinguishes
0
from-0
which was already the case before my change. It is not the case of the suggested change:As in JavaScript
-0 === 0
🤔Alternatively we can use:
Object.is(+a, +b)
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.
Good point. So actually we have four symmetric options, from most to least fuzzy:
(1)
+0 === -0
and values that approach zero from the same side are equivalent.(2)
+0 !== -0
and values that approach zero from the same side are equivalent.(3)
+0 === -0
, otherwise exact comparison.(4)
+0 !== -0
, entirely likeObject.is
but compatible with IE.