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

value = (comparator || value !== 0) ? value : 0; does it work? #3175

Closed
fi3ework opened this issue May 30, 2017 · 4 comments
Closed

value = (comparator || value !== 0) ? value : 0; does it work? #3175

fi3ework opened this issue May 30, 2017 · 4 comments
Labels

Comments

@fi3ework
Copy link

fi3ework commented May 30, 2017

value = (comparator || value !== 0) ? value : 0;

in https://github.com/lodash/lodash/blob/master/.internal/baseDifference.js#L46
what does this sentence mean? Is it useless? :-)

@jdalton
Copy link
Member

jdalton commented May 30, 2017

Hi @fi3ework!

That bit ensures that a positive 0 is used because -0 is a thing in JS.

@jdalton jdalton closed this as completed May 30, 2017
@fi3ework
Copy link
Author

@jdalton
yeah, I know the exist of -0, but why change -0 to +0 ? Why not just use -0 directly? :-)

@jdalton
Copy link
Member

jdalton commented May 30, 2017

Because internally we use Set for deduping and Set doesn't distinguish between the two.

@lock
Copy link

lock bot commented Dec 27, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Dec 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

2 participants