Honestly for me, forEach is "too little too late" and a bloated wreck that gets callbacks involved for NOTHING. Particularly when the painfully and needlessly cryptic arrow function trash gets involved, and in the face of for/of.

For/of makes foreach look like ignorant incompetent trash, used by "function for nothing" fanboys who in all likelihood need to go back and learn the basics.

EVERY time you call a function you're introducing extra overhead. Be it execution speed in firefox and legacy browsers, or part of why Chrome is such a memory hog where it tries to go ape-shit optimizing bad code. As such putting a function call inside the loop is utter trash.

Again, especially so when for/of can do the same job without the "function for nothing" or cryptic syntax, destructuring can pull the index if you need it, etc, etc.

Also remember, array.push is actually slower than [Array.length] =. Sucks, huh?


Written by

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store