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 (Macintosh; Intel Mac OS X 10.15; rv:144.0) Gecko/20100101 Firefox/144.0
Browser:
Firefox 144
Operating system:
Mac OS X 10.15
Device Platform:
Desktop
Date tested:
5 months ago
Test name
Executions per second
slice
56964256.0 Ops/sec
push
54154104.0 Ops/sec
Spread
16376876.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]