Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Array slice vs for loop vs spread (new Array)
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Android 15; Mobile; rv:137.0) Gecko/137.0 Firefox/137.0
Browser:
Firefox Mobile 137
Operating system:
Android
Device Platform:
Mobile
Date tested:
one year ago
push
29.9M/s
slice
26.2M/s
Spread
8.7M/s
View exact numbers
Test name
Executions per second
✓
push
29,912,088 Ops/sec
slice
26,205,038 Ops/sec
Spread
8,743,147 Ops/sec
Script Preparation code:
const data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
Tests:
slice
const copy = data.slice(0, 5);
push
const copy = new Array(5); for (let i = 0; i < 5; i++) { copy[i] = data[i]; }
Spread
const copy = [...data]