Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:131.0) Gecko/20100101 Firefox/131.0
Firefox 131
Mac OS X 10.15
Desktop
3 months ago
Test name Executions per second
Array.slice() 69146.9 Ops/sec
Spread operator 10869.4 Ops/sec
HTML Preparation code:
AخA
 
1
<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]