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 |
<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)