3 ms·
In my experience, there is almost never a need for creating a loop on an array purely for the sake of side effect. For instance, if you want to write something
by splintercell 9y ago
In my experience, there is almost never a need for creating a loop on an array purely for the sake of side effect.
For instance, if you want to write something on the log, then loop and collect everything into a single array (using map) and then perform the side effect with a single command (which is a lot more performant in most cases).
For asynchronous side effects, create an array of promises using a map, and then run a Promise.all() on that array if you need to resolve all of them.
But again, if your experience is different or in your requirements, it is not possible to create a map/reduce/filter transoformation for side effects, then I'd love to hear about it.