How I discovered my love for JavaScript after throwing 90% of it in the trash
hackernoon.com
hackernoon.com
The whole point of abstraction (functional or object-oriented) is to push that logic from control structures in code to composition structures in runtime data.
If you weren't replacing conditionals with polymorphism, you weren't doing object-oriented programming in the first place.
For loops in JS are significantly faster than .forEach() or .map()
When performance matters (WebAudio, WebGL etc), you can't easily get rid of for loops just yet.
I'm not disagreeing with you, I actually don't know, and am always happy to learn useful facts for refactoring and improved performance :)
Some of the popular JS frameworks actually re-implement an array.forEach function as an internal for-loop to mitigate this.
I am not sure of why this is the case, and I am also not sure if the situation has improved or not since I last had to deal with the performance difference.
edit: The mozilla page about this has a polyfill for the forEach method, that shows it does more than a simple for loop:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
Personally I use the functional methods whenever I can, but the original quote I re-posted indicates that the author thinks that for-loops should always be replaced with their functional equivalents, and I was just pointing out that this is not universally a good idea yet.
Personally I found the whole article very skippable. None of it is necessarily terrible advice, but everything is overstated, and said without really explaining why its advice better than the alternatives.