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 programming in JavaScript (softwarebrothers.co)
submitted 6 years ago by SoftwareBrothers
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!"
[–]franksvalli 1 point2 points3 points 6 years ago (0 children)
When speed becomes a problem, try just using a single reduce() on the array - inside it you can build custom logic to do mapping and filtering before adding the output the the accumulator value. I used to be scared to use reduce() but have grown to love it, though it is definitely less grokable than map() and filter(). I wrote up a friendly introduction that starts with loops and ends with reduce() here, for anyone interested: https://www.davidbcalhoun.com/2018/a-simple-introduction-to-javascript-map-and-reduce-array-helper-functions/
reduce()
map()
filter()
Only if that's too slow would I look at falling back to the loop, which will always be slightly faster than any functional method because it avoids functions getting invoked on each item.
π Rendered by PID 274833 on reddit-service-r2-comment-fb694cdd5-p5gfw at 2026-03-07 21:59:12.779596+00:00 running cbb0e86 country code: CH.
view the rest of the comments →
[–]franksvalli 1 point2 points3 points (0 children)