Test name | Executions per second |
---|---|
1 | 6.6 Ops/sec |
2 | 6.6 Ops/sec |
3 | 9.8 Ops/sec |
4 | 5.1 Ops/sec |
5 | 5.2 Ops/sec |
6 | 16.5 Ops/sec |
7 | 14.4 Ops/sec |
var array = new Array(1000000).fill(0);
function getObj() {
return {x: 0, Y: 0};
}
for (let i = 0; i < array.length; i++) array[i] = getObj();
for (let i = 0; i < array.length; ++i) array[i] = getObj();
const l = array.length;
for (let i = 0; i < l; ++i) array[i] = getObj();
for (const i in array) array[i] = getObj();
let i;
for (i in array) array[i] = getObj();
const arr2 = array.map(_ => getObj());
const arr3 = [];
for (let i = 0; i < 1000000; i++) arr3.push(getObj());