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
Lodash cloneDeep 1040818.6 Ops/sec
Lodash clone 13621489.0 Ops/sec
Array.slice() 42414548.0 Ops/sec
Object.assign() 2998901.2 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 = ['one', 'two', 'three', {four: 'five'}];
Tests:
  • Lodash cloneDeep

     
    var myCopy = _.cloneDeep(arr)
  • Lodash clone

     
    var myCopy = _.clone(arr)
  • Array.slice()

     
    var myCopy = arr.slice()
  • Object.assign()

     
    var myCopy = Object.assign([], arr)