Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Array.slice() vs. Spread operator
For times when a shallow copy of an Array 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()
37555376.0 Ops/sec
Spread operator
18941918.0 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 = ['one', 'two', 'three', {four: 'five'}];
Tests:
Array.slice()
var myCopy = arr.slice()
Spread operator
var myCopy = [...arr]