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 |
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.20/lodash.min.js'></script>
var arr = ['one', 'two', 'three', {four: 'five'}];
var myCopy = _.cloneDeep(arr)
var myCopy = _.clone(arr)
var myCopy = arr.slice()
var myCopy = Object.assign([], arr)