HTML Preparation code:
x
 
1
2
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
3
<script src='https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.0/moment.min.js'></script>
Script Preparation code:
 
arr = [];
for (let i = 0; i < 200; i += 1) {
    arr.push({
      name: `Person${i}`,
      birthday: moment().add(i, 'days').toDate(),
    });
  }
Tests:
  • Lodash cloneDeep

     
    const cloneArr = _.cloneDeep(arr);
  • Deep clone with JSON.parse(JSON.stringify(obj))

     
    const cloneArr = JSON.parse(JSON.stringify(arr));
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Lodash cloneDeep
    Deep clone with JSON.parse(JSON.stringify(obj))

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36
Chrome 119 on Linux
View result in a separate tab
Test name Executions per second
Lodash cloneDeep 4115.1 Ops/sec
Deep clone with JSON.parse(JSON.stringify(obj)) 5739.2 Ops/sec