-
Notifications
You must be signed in to change notification settings - Fork 7k
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
sumBy returns boolean instead of number #4878
Comments
Hi! The behavior is really wrong, I made a simple solution here, can I take this like a bug-fix? |
Easiest solution is to always make sure your Example: I created a PR for the fix here #4883 Anyone know how to run all the tests for lodash? I didn't have time to figure it out.
fails because it can't create |
Same here, I was looking at #4865 , and could not figure out how to run all the tests. |
I believe this behaviour is working as intended for now. Although |
I am not sure how is this issue is closed (as well as the closed "duplicates" for null), as I can sum strings (it will concatenate). It might be expected behaviour, but if so - the documentation should change to reflect the return value is not always a number (it can also still return a null or undefined, if all the values are such) |
Where is the "fresh start" for this issue? I see many like issues (for instance, the sum() return 0 for null, and [null, null] yet return null for [null]), but all are closed, or marked as duplicate to other closed one. It seems no solution was expected. We use the overhead of lodash in our codebase, as it is stable - on opposition to many quirks of pure javascript. So, it's not an excuse that js has unexpected behavior to leave it like this. |
_.sumBy([true], (i) => i === true)
Actual returns:
true
Expected:
1
The text was updated successfully, but these errors were encountered: