Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
new Array from vs slice vs push vs index vs spread
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (iPhone; CPU iPhone OS 17_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2 Mobile/15E148 Safari/604.1
Browser:
Mobile Safari 17
Operating system:
iOS 17.2
Device Platform:
Mobile
Date tested:
2 years ago
Array.push
3.8M/s
Array[index]
3.4M/s
Array.slice
2.8M/s
Array spread
2.0M/s
Array.from
2.0M/s
View exact numbers
Test name
Executions per second
✓
Array.push
3,820,364 Ops/sec
Array[index]
3,408,000 Ops/sec
Array.slice
2,840,523 Ops/sec
Array spread
2,045,551 Ops/sec
Array.from
1,980,398 Ops/sec
Tests:
Array.from
const elements = document.all; const arr = Array.from(elements);
Array.slice
const elements = document.all; const arr = Array.prototype.slice.call(elements, 0);
Array.push
const elements = document.all; const amount = elements.length; const arr = []; for (let i = 0; i < amount; i += 1) arr.push(elements[i]);
Array[index]
const elements = document.all; const amount = elements.length; const arr = Array(amount); for (let i = 0; i < amount; i += 1) arr[i] = elements[i];
Array spread
const elements = document.all; const arr = [...elements];