Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36
Chrome 123
Windows
Desktop
9 months ago
Test name Executions per second
Lodash cloneDeep 1177911.1 Ops/sec
Lodash clone 6397630.5 Ops/sec
Array.slice() 17987868.0 Ops/sec
Object.assign() 1143974.0 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)