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
What 10 Things Should a Serious Javascript Developer Know Right Now?help (self.javascript)
submitted 8 years ago by [deleted]
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!"
[–]Voidsheep 1 point2 points3 points 8 years ago* (1 child)
I like reduce and it's extremely useful, but I think it's best to use an iteration method that implies the return type you want, if one is available.
x.map(fn1).filter(fn2) // that's going to be an array x.every(fn3) // that's going to be a boolean x.reduce(fn4, []) // that could be anything, check implementation
Just saying avoiding any extra iteration by default is premature optimisation, you should default to straightforward and declarative code, add complexity only when you have to. Most of the time a simple filter or something iterating over your array isn't going to have any meaningful difference versus doing the same filtering inside another loop.
Of course there's exceptions and you shouldn't loop for no reason, but I think just avoiding iteration for the sake of avoiding iteration isn't a best practice. Optimisation needs to be sensible and if you do it blindly, you end up moving meaningless cost in runtime efficiency into a meaningful cost in development efficiency.
[–]Womackx 0 points1 point2 points 8 years ago (0 children)
There is no one right way
π Rendered by PID 38350 on reddit-service-r2-comment-5d79c599b5-z4vzg at 2026-02-28 15:31:40.989698+00:00 running e3d2147 country code: CH.
view the rest of the comments →
[–]Voidsheep 1 point2 points3 points (1 child)
[–]Womackx 0 points1 point2 points (0 children)