Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Angular merge vs lodash merge
Angular merge vs lodash merge
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36
Browser:
Chrome 124
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
Angular merge
1005307.0 Ops/sec
Lodash merge
2753281.0 Ops/sec
HTML Preparation code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.8/angular.min.js"></script>
Script Preparation code:
var obj1 = { firstName: 'Ronald', lastName: 'Reagan', password: '23k4jlqrkjq2343q', hairColor: 'brown' }; var obj2 = { firstName: 'James', hairColor: 'black', phoneNumber: '8055555555' } function merge(destination, source) { angular.forEach(source, function(value, key) { if (angular.isDefined(destination[key])) { if (angular.isObject(destination[key]) && !angular.isArray(destination[key])) { destination[key] = merge(destination[key], source[key]); } else { destination[key] = source[key]; } } else { // adds value to the destination object destination[key] = source[key]; } }); return destination; }
Tests:
Angular merge
var newObj = merge(obj1, obj2);
Lodash merge
var newObj = _.merge(obj1, obj2);