I though this was on the topic of overusing reduce which was brought up by Jake Archibald recently on twitter.
They were arguing that beside summing, reduce should be avoided in favor of for loops as they were easier to read and faster.
for
Object.fromEntries can help remove a lot of reduces too when generating objects.
Object.fromEntries
If you want a method to rule them all, reduce is your best bet, but don't.
reduce
Learn map and filter they have very clear and distinct roles, now days I favor for..of over forEach.
map
filter
for..of
forEach
Yes correct. I brought this up to highlight the other sentiment which is: 'use map/forEach all the time', even in cases where reduce could have been your best bet. This is another awesome video on the same topic:
Yes well, that's jake haha
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I though this was on the topic of overusing reduce which was brought up by Jake Archibald recently on twitter.
They were arguing that beside summing, reduce should be avoided in favor of
for
loops as they were easier to read and faster.Object.fromEntries
can help remove a lot of reduces too when generating objects.If you want a method to rule them all,
reduce
is your best bet, but don't.Learn
map
andfilter
they have very clear and distinct roles, now days I favorfor..of
overforEach
.Yes correct. I brought this up to highlight the other sentiment which is: 'use map/forEach all the time', even in cases where reduce could have been your best bet.
This is another awesome video on the same topic:
Yes well, that's jake haha