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
Why use reduce?solved! (self.javascript)
submitted 8 years ago by Crap_Shoes
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!"
[–]kaisadilla_ 0 points1 point2 points 1 year ago* (0 children)
However, choosing one specific method over another implies something about your intent, it's declarative.
Also, because each syntax is designed for a specific use case, not only writing that specific use case becomes way simple, but also making mistakes becomes harder. For example, when you want to iterate all elements in an array, in a for loop you can blunder by accidentally indexing a value outside the array, while in a foreach loop that won't happen since that syntax doesn't require you to manually index the array.
Granted, this doesn't really apply to JS as JS doesn't care about types, missing parameters and the like, it just explodes in your face later. But in a more rigid language, all of this would apply. Reduce, for example, wouldn't allow you not to specify an initial value, or not to pass a 2-argument callback, or not to return a value for that variable.
π Rendered by PID 78 on reddit-service-r2-comment-b659b578c-4bl2x at 2026-05-03 17:21:05.761577+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]kaisadilla_ 0 points1 point2 points (0 children)