DEV Community

Discussion on: What s wrong with Array.reduce ?

Collapse
 
dvddpl profile image
Davide de Paolis

mmm. but this is true also for array.foreach and array.map etc. and i find those much nicer and simpler. I love reduce. but i kind of agree with the rant in the tweet to some extent

Collapse
 
vonheikemen profile image
Heiker

I'm just repeating the only argument against reduce I think it make sense. By some misfortune reduce doesn't seem to "click" with people in the same way map, filter or forEach do.

Thread Thread
 
jbristow profile image
Jon Bristow

which is a shame, because map, filter, and forEach are just reduce in disguise.

Thread Thread
 
alainvanhout profile image
Alain Van Hout

Though, for completeness, all of those are just loops in disguise (which isn't an argument for or against it).

Thread Thread
 
jbristow profile image
Jon Bristow • Edited

Only if you consider loops and tail recursion to be the same thing, which is debatable.

Also, it's only the same when applied to lists.

Other monadic structures may not act as loops at all, when called with reduce aka fold