Comment

Comment by brundolf

FP is about avoiding side-effects; forEach() can only cause side-effects, so it's not really functional at all, and yet it's superficially designed to blend in with the actual functional array methods like map().

IMO it's the worst of both worlds and there's virtually never a good reason to use it. If you're going to write a side-effect-y loop, a classic for-loop (or more often, a for..of loop) helps to emphasize that the code is side-effect-y.

parent brundolf 4 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton