Test name | Executions per second |
---|---|
foreach | 235276.0 Ops/sec |
for-in | 26673.7 Ops/sec |
for-of | 205696.7 Ops/sec |
for | 252250.8 Ops/sec |
optimized-for | 231390.8 Ops/sec |
const items = Array.from({length: 1000}, () => Math.floor(Math.random() * 40));
let index = 0;
items.forEach(i => index++);
const items = Array.from({length: 1000}, () => Math.floor(Math.random() * 40));
let index = 0;
for (let i in items) {
index++;
}
const items = Array.from({length: 1000}, () => Math.floor(Math.random() * 40));
let index = 0;
for (let i of items) {
index++;
}
const items = Array.from({length: 1000}, () => Math.floor(Math.random() * 40));
let index = 0;
for(let i = 0; i < items.length; ++i) {
index++;
}
const items = Array.from({length: 1000}, () => Math.floor(Math.random() * 40));
let index = 0;
for(let i = items.length; i > 0; --i) {
index++;
}