Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
4-number (float) 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_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.4 Safari/605.1.15
Browser:
Safari 18
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Array.slice() with start and end
118.4M/s
Array.slice() with start
108.5M/s
Array.slice()
105.8M/s
Spread operator
59.5M/s
View exact numbers
Test name
Executions per second
✓
Array.slice() with start and end
118,415,584 Ops/sec
Array.slice() with start
108,515,072 Ops/sec
Array.slice()
105,831,504 Ops/sec
Spread operator
59,453,896 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 = [1.9, 2.8, 3.7, 4.6];
Tests:
Array.slice()
var myCopy = arr.slice()
Spread operator
var myCopy = [...arr]
Array.slice() with start and end
var myCopy = arr.slice(0, 3)
Array.slice() with start
var myCopy = arr.slice(0)