Test name | Executions per second |
---|---|
Array.from | 289680.4 Ops/sec |
Array.slice | 342524.7 Ops/sec |
Array.push | 1181625.9 Ops/sec |
Array[index] | 1037557.1 Ops/sec |
Array spread | 312581.2 Ops/sec |
const elements = document.all;
const arr = Array.from(elements);
const elements = document.all;
const arr = Array.prototype.slice.call(elements, 0);
const elements = document.all;
const amount = elements.length;
const arr = [];
for (let i = 0; i < amount; i += 1) arr.push(elements[i]);
const elements = document.all;
const amount = elements.length;
const arr = Array(amount);
for (let i = 0; i < amount; i += 1) arr[i] = elements[i];
const elements = document.all;
const arr = [elements];