|
|
|
|
|
by hdhzy
3306 days ago
|
|
Well if you're comparing for loop to reduce or map in JavaScript then for will always win as it is a built in language construct and reduce involves costly callbacks. Interesting that the difference is only 7% on my Chrome for Android [0]. [0]: https://jsperf.com/foreach-vs-reduce-vs-for-loop For loops have also an advantage that they can be used with yield and await (generators and async functions) while you cannot place these keywords inside a callback function. |
|