In some situations we have to consider code readability over to-the-nanosecond performance.
But yeah, it is well known that the classic for-loop outperforms any other loop by a very large margin.
Following @si
response. Please note that it is (not probably, with absolute certainty) a bad practice to use map instead of forEach. But the fact is that map can run twice as fast as forEach, which is boringly slow.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Looking at perf, the basic for loop is superior to any of the other. jsperf.com/for-vs-foreach/75.
And Array.prototype.map merits to be considered as an alternative to foreach jsperf.com/loop-vs-map-vs-foreach.
In some situations we have to consider code readability over to-the-nanosecond performance.
But yeah, it is well known that the classic for-loop outperforms any other loop by a very large margin.
Following @si response. Please note that it is (not probably, with absolute certainty) a bad practice to use map instead of forEach. But the fact is that map can run twice as fast as forEach, which is boringly slow.