DEV Community


Discussion on: We Don't Need No Stinking map() or filter()

alainvanhout profile image
Alain Van Hout

Before anyone would be inclinded to use reduce for everything, since it indeed can be used to do all the things that mapand filter(as well as someand any), keep in mind that the same could be said (and then some) about a traditional for loop.

As to using reduce when you want to combine different operations, again note that the same would be true for a forloop. Neither a for loop nor reduceshould be used in those cases, for the very same reason: you sacrifice legilibity (and the next developer that has to modify your code won't be thanking you for your cleverness).