Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Array.slice() vs. Spread operator (10000 items)
For times when a shallow copy of an Array of size 10000 is needed, what is the performance difference between these 2 methods.
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:131.0) Gecko/20100101 Firefox/131.0
Browser:
Firefox 131
Operating system:
Mac OS X 10.15
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Array.slice()
101893.7 Ops/sec
Spread operator
10844.4 Ops/sec
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.20/lodash.min.js'></script>
Script Preparation code:
var arr = new Array(10000).fill(0);
Tests:
Array.slice()
var myCopy = arr.slice()
Spread operator
var myCopy = [...arr]