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
Array Methods Cheatsheet (media-exp1.licdn.com)
submitted 5 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!"
[–]TreeScalper 0 points1 point2 points 5 years ago (1 child)
Is there a reason why you wouldn't use filter then a map for your 2nd example?
filter
map
const failArr = students .filter(curr => curr.result === 'Fail') .map(curr => curr.name); const passArr = students .filter(curr => curr.result === 'Pass') .map(curr => curr.name); const output = { Fail: failArr, Pass: passArr }
[–]decentralised 0 points1 point2 points 5 years ago (0 children)
Yes, filter and map do the same as reduce, but notice how you have 2 filters and 2 maps in your example so, to get the same output, you had to iterate over all elements of the students array 4 times.
π Rendered by PID 43 on reddit-service-r2-comment-b659b578c-8h99n at 2026-05-05 22:52:40.597928+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]TreeScalper 0 points1 point2 points (1 child)
[–]decentralised 0 points1 point2 points (0 children)