Test name | Executions per second |
---|---|
foreach | 93.1 Ops/sec |
for | 54.7 Ops/sec |
map | 86.5 Ops/sec |
var arr = [];
for (var i = 0; i < 100000; 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))