DEV Community

loading...

Discussion on: "for" vs. "forEach" and the value of documentation

Collapse
_andys8 profile image
Andy • Edited

In the example find is the solution that is the best description for the wanted behavior.

In general, if you "wanted perform some calculations on each item of an array", prefer map (a pure transformation of each object) over imperative for and forEach.

Collapse
swarupkm profile image
Swarup Kumar Mahapatra

Totally agree . People who start programming, generally they start with the procedural paradigm of programming. for loop is one the first thing that people come across (along with if-else). That sticks to their mind forever , until functional programming is introduced to them . Its just matter of time to get used to such paradigm . I am pretty sure with few weeks, the author of the article will be very well versed in functional programming