Test name | Executions per second |
---|---|
foreach | 10864.6 Ops/sec |
for | 5445.9 Ops/sec |
map | 9812.1 Ops/sec |
for of | 11551.4 Ops/sec |
var arr = [];
for (var i = 0; i < 1000; i++) {
arr[i] = i;
}
function someFn(i) {
return i * 3 * 8;
}
arr.forEach(function (item){
someFn(item);
})
for (var i = 0, len = arr.length; i < len; i++) {
someFn(arr[i]);
}
arr.map(item => someFn(item))
for (let i of arr) {
someFn(i);
}