DEV Community

Discussion on: Stop using for loops. Here's why.

Collapse
 
blindfish3 profile image
Ben Calder

Agreed on most counts. You don't mention that for loops also allow you to break out of the loop early; which depending on context can provide performance benefits.

There is very little good usage for reduce.

On the contrary, there are some incredibly useful applications for reduce and it can often be used when a normal for loop seems like the only option.

Collapse
 
lluismf profile image
Lluís Josep Martínez

You can't use BREAK or CONTINUE in a foreach/filter/map etc. Normal for loops are there for a reason.