Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Lodash cloneDeep vs Lodash clone vs Array.slice() vs. Object.assign()
For times when a shallow copy is needed, what is the performance difference between these 3 methods.
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:132.0) Gecko/20100101 Firefox/132.0
Browser:
Firefox 132
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Array.slice()
44.6M/s
Lodash clone
21.4M/s
Object.assign()
3.8M/s
Lodash cloneDeep
1.2M/s
View exact numbers
Test name
Executions per second
✓
Array.slice()
44,618,324 Ops/sec
Lodash clone
21,354,164 Ops/sec
Object.assign()
3,808,197 Ops/sec
Lodash cloneDeep
1,229,781 Ops/sec
HTML Preparation code:
<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)