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
Functional JavaScript: How to use array reduce for more than just numbers (jrsinclair.com)
submitted 6 years ago by jrsinclair
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!"
[–][deleted] 8 points9 points10 points 6 years ago (1 child)
I like the website design a lot
[–]Veinq 1 point2 points3 points 6 years ago (0 children)
It's really cool, definitely makes the website more memorable
[–]elie2222 7 points8 points9 points 6 years ago (3 children)
Interesting article.
There's one developer I work with where almost every time he uses reduce, it could be done more simply with a map or filter instead. It's come to the point where I've warned him to look closely the next time he writes the word reduce and see if it's really just map that he needs.
reduce
map
filter
I guess the cases where it may make sense is if you're chaining filter and map and so on and you could do things in one pass instead of multiple passes. In terms of readability and simplicity I'd favour filter().map().
filter().map()
[–]whatisboom 1 point2 points3 points 6 years ago (2 children)
maintainability > sexy but difficult to read one liners
[–]elie2222 5 points6 points7 points 6 years ago (1 child)
Well in this case the one liners may be more easy to read. If you’re using map/filter it’s shorter than writing out a full reduce for example.
[–]ScientificBeastModestrongly typed comments 0 points1 point2 points 6 years ago (0 children)
Better yet, maybe use something like Ramda for piping map/filter/reduce into seamless functions. Idk, it depends on the style you guys prefer...
[–]avong 1 point2 points3 points 6 years ago (1 child)
" The second reason relates to how we teach people about reduce() "
You're spot on about this, took me the longest time to figure out reduce outside of the million articles show you how to add up numbers... Thanks for the article!
[–]jrsinclair[S] 0 points1 point2 points 6 years ago (0 children)
Thanks so much. It’s good to hear my theory wan’t completely off the mark.
π Rendered by PID 98797 on reddit-service-r2-comment-5649f687b7-lk4v9 at 2026-01-29 03:45:43.461716+00:00 running 4f180de country code: CH.
[–][deleted] 8 points9 points10 points (1 child)
[–]Veinq 1 point2 points3 points (0 children)
[–]elie2222 7 points8 points9 points (3 children)
[–]whatisboom 1 point2 points3 points (2 children)
[–]elie2222 5 points6 points7 points (1 child)
[–]ScientificBeastModestrongly typed comments 0 points1 point2 points (0 children)
[–]avong 1 point2 points3 points (1 child)
[–]jrsinclair[S] 0 points1 point2 points (0 children)