Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Lodash extend vs Object.assign
Compare lodash extend vs Object.assign
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:133.0) Gecko/20100101 Firefox/133.0
Browser:
Firefox 133
Operating system:
Ubuntu
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Lodash extend
8.1 Ops/sec
Object.assign
29.5 Ops/sec
With ...
17.0 Ops/sec
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.11/lodash.min.js"></script>
Script Preparation code:
var arr = []; var object1 = { propa: { a: 1, b: 1 }, propb: { a: 1, b: 1 }, propc: { a: 1, b: 1 } }; var object2 = { propa: { a: 1, d: 1 }, propb: { a: 1, d: 1 }, propd: { a: 1, d: 1 } }; for (var i = 0; i <= 100000; i++) { arr.push({ object1, object2 }); }
Tests:
Lodash extend
arr.map(function (element) { const { object1, object2 } = element; let results = {}; [object1, object2].forEach(elem => { for (const propy in elem) { results[propy] = _.extend({}, elem[propy], results[propy]); } }); });
Object.assign
arr.map(function (element) { const { object1, object2 } = element; let results = {}; [object1, object2].forEach(elem => { for (const propy in elem) { if (!results[propy]) { results[propy] = {}; } Object.assign(results[propy], elem[propy]); } }); });
With ...
arr.map(function (element) { const { object1, object2 } = element; let results = {}; [object1, object2].forEach(elem => { for (const propy in elem) { if (!results[propy]) { results[propy] = {}; } results[propy] = { ...results[propy], ...elem[propy] }; } }); });