DEV Community

loading...

Discussion on: Why you should give Array.prototype.reduce() a chance too?🧐

Collapse
kigiri profile image
Clément

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 and filter they have very clear and distinct roles, now days I favor for..of over forEach.

Collapse
comscience profile image
kapeel kokane Author

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:

Collapse
kigiri profile image
Clément

Yes well, that's jake haha