-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Wrong value for _.isEqual(0, new Number(Number.MIN_VALUE)) #2815
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1223,7 +1223,7 @@ | |||||||||||||
// Object(NaN) is equivalent to NaN. | ||||||||||||||
if (+a !== +a) return +b !== +b; | ||||||||||||||
// An `egal` comparison is performed for other numeric values. | ||||||||||||||
return +a === 0 ? 1 / +a === 1 / b : +a === +b; | ||||||||||||||
return +a === 0 && +b === 0 ? 1 / +a === 1 / b : +a === +b; | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This just collapses the entire expression to
Suggested change
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:
Suggested change
However, maybe there is something to say for making the comparison symmetrically exact instead of symmetrically fuzzy:
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually this is not fully equivalent. The initial check distinguishes --- return +a === 0 && +b === 0 ? 1 / +a === 1 / b : +a === +b;
+++ return +a === +b; As in JavaScript There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) +a === +b || 1 / +a === 1 / +b (2) +a === 0 || +b === 0 ? 1 / +a === 1 / +b : +a === +b (3) +a === +b (4) +a === 0 && +b === 0 ? 1 / +a === 1 / +b : +a === +b |
||||||||||||||
case '[object Date]': | ||||||||||||||
case '[object Boolean]': | ||||||||||||||
// Coerce dates and booleans to numeric primitive values. Dates are compared by their | ||||||||||||||
|
Uh oh!
There was an error while loading. Please reload this page.