DEV Community

Discussion on: filter, map and reduce in JS. When and Where to use??

nehal_mahida profile image
Nehal Mahida Author

Definitely a good point 👏🏻

Performance vs readability is a never-ending debate.

I intend how we can avoid two methods by just using reduce and explaining to the people how to use reduce syntactically!!

And yes, for loop is there to achieve all of these things.

lukeshiru profile image

You can explain reduce with a sum and is clear enough:

const numbers = [1, 2, 3];
numbers.reduce((total, number) => total + number, 0); // 6
Enter fullscreen mode Exit fullscreen mode