Test name | Executions per second |
---|---|
For i | 10608.9 Ops/sec |
For of | 184306.3 Ops/sec |
ForEach | 148914.5 Ops/sec |
var testingArray = new Array(1000).fill(1);
const newArr = [];
for (let i = 0, item; (item = testingArray[i]); i += 1) {
newArr.push(item);
}
const newArr = [];
for (const item of testingArray) {
newArr.push(item);
}
const newArr = [];
testingArray.forEach(item => {
newArr.push(item);
});