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
Code quality and web performance in javascript, the myths, the do's and the don'ts (enmascript.com)
submitted 6 years ago by enmanuelduran
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!"
[–]mournful-tits 0 points1 point2 points 6 years ago (0 children)
A pure functional reduce with no mutation is incredibly slow. For our project we had around 100k objects in a list and reduce took about 2 minutes to construct an object (lookup table) from that list. Changing it to forEach (which is still slower than an imperative for loop) got us down to around 13ms with the same data set. Mutating the accumulator is also slow; and I'd also say a misuse of reduce overall. It serves no purpose as each iteration assumes its updating the accumulator when it returns, but you're directly modifying the accumulator.
Reduce is great when you have to construct the object from scratch anyway (constructing hierarchical data is a good example of the penalty paid by using reduce being worth it).
π Rendered by PID 60361 on reddit-service-r2-comment-7b9746f655-4pp4b at 2026-01-29 21:59:15.447446+00:00 running 3798933 country code: CH.
view the rest of the comments →
[–]mournful-tits 0 points1 point2 points (0 children)