Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Array slice vs for loop vs spread (new Array)
(version: 1)
Comparing performance of:
slice vs push vs Spread
Created:
one year ago
by:
Guest
Go to the latest result
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]
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
slice
push
Spread
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
6 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.2 Safari/605.1.15
Browser/OS:
Safari 26 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
push
314.6M/s
slice
149.7M/s
Spread
72.0M/s
View exact numbers
Test name
Executions per second
✓
push
314,624,832 Ops/sec
slice
149,744,832 Ops/sec
Spread
71,954,904 Ops/sec
Related benchmarks
Array slice vs for loop
Array slice vs for loop (new Array)
Array slice vs for loop (2)
array clone variants
Comments
Confirm delete:
Do you really want to delete benchmark?