Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Array clone (spread vs slice vs array.from)
(version: 1)
Comparing performance of:
Spread vs Slice vs Array.from
Created:
one year ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
const array = Array.from({ length: 128000 }, (_, i) => { return { i } })
Tests:
Spread
const copy = [...array];
Slice
const copy = array.slice();
Array.from
const copy = Array.from(array);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Spread
Slice
Array.from
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
5 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36
Browser/OS:
Chrome 142 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Spread
4627.2 Ops/sec
Slice
4520.1 Ops/sec
Array.from
4667.5 Ops/sec
Related benchmarks:
Array cloning: slice vs spread
JavaScript array copy via spread op vs slice
Slice vs spread array
Array.prototype.slice vs spread op
JS Array Slice vs Array Spread
Shallow Copy Array
Array cloning 2023
Array.from() vs Spread operator
Clone and append to array
Comments
Confirm delete:
Do you really want to delete benchmark?