Re:How I discovered my love for JavaScript after throwing 90...
by satori99 on Sunday September 17, 2017 @09:13PM
(#15272698)
There are plenty of online benchmarks that show this. jsperf is down for me atm, so i can't provide a link.
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...
I'm not disagreeing with you, I actually don't know, and am always happy to learn useful facts for refactoring and improved performance :)