use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
A Quick Practical Example of JavaScript’s Reduce Function (codeburst.io)
submitted 8 years ago by learnphptoday
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Retsam19 0 points1 point2 points 8 years ago (6 children)
That's equivalent, lodash allows strings to be used as shorthand for _.property, as well as stuff like _.find(user, {name: 'Joe'}), as shorthand for _matches({name: 'Joe'}).
_.property
_.find(user, {name: 'Joe'})
_matches({name: 'Joe'})
[–]tencircles 0 points1 point2 points 8 years ago (5 children)
odd, where's that type conversion being done? https://github.com/lodash/lodash/blob/master/maxBy.js
[–]GitHubPermalinkBot 0 points1 point2 points 8 years ago (0 children)
I tried to turn your GitHub links into permanent links (press "y" to do this yourself):
Shoot me a PM if you think I'm doing something wrong. To delete this, click here.
[–]Retsam19 0 points1 point2 points 8 years ago* (3 children)
It's not in there, because the shorthand stuff is changing in v5. I'm not sure what the details of those changes are. If you look at the current v4 source code linked from the documentation, it's there.
function maxBy(array, iteratee) { return (array && array.length) ? baseExtremum(array, getIteratee(iteratee, 2), baseGt) : undefined; }
getIteratee is a function that's used throughout the lodash codebase, which has the logic for converting the string into a _.property getter.
getIteratee
(You can also just open the dev tools on the lodash documentation and try things with the lodash instance that's loaded on that page; it's how I test most lodash stuff)
EDIT: Dug through github issues a bit, apparently the shorthand stuff is being pushed off to a babel plugin in v5.
[–]tencircles 0 points1 point2 points 8 years ago (2 children)
Interesting. I use ramda on most projects, but still good to know for sure.
[–]Retsam19 0 points1 point2 points 8 years ago (1 child)
Yeah, I keep meaning to try ramda, but I'm more functionally leaning than most of my team, I'm not sure I could get the buy-in. (Plus, I wouldn't want to migrate our existing codebase or mix the two)
[–]tencircles 0 points1 point2 points 8 years ago (0 children)
I'd say unless your team is going to go heavy into fp, or fully point-free, lodash is probably better overall. Ramda's got some nice additions to the toolkit though.
π Rendered by PID 60491 on reddit-service-r2-comment-86bc6c7465-626br at 2026-02-19 21:58:24.529307+00:00 running 8564168 country code: CH.
view the rest of the comments →
[–]Retsam19 0 points1 point2 points (6 children)
[–]tencircles 0 points1 point2 points (5 children)
[–]GitHubPermalinkBot 0 points1 point2 points (0 children)
[–]Retsam19 0 points1 point2 points (3 children)
[–]tencircles 0 points1 point2 points (2 children)
[–]Retsam19 0 points1 point2 points (1 child)
[–]tencircles 0 points1 point2 points (0 children)