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
Array.slice()
37.6M/s
Spread operator
18.9M/s
View exact numbers
Test name
Executions per second
✓
Array.slice()
37,555,376 Ops/sec
Spread operator
18,941,918 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]