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
Test name
Executions per second
slice
26205038.0 Ops/sec
push
29912088.0 Ops/sec
Spread
8743147.0 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]