merge or spread

Benchmark created on


Preparation HTML

<script src="
https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js
"></script>

Setup

const objA = {a: '1', aa: '1', aaa: '1'};
const objB = {b: '2', bb: '2', bbb: '2'};
const objC = {c: '3', cc: '3', ccc: '3', a: 3};

const arr = [objA, objB, objC];

Test runner

Ready to run.

Testing in
TestOps/sec
lodash
arr.reduce((acc, curr) => _.merge(acc, curr), {});
ready
spread
arr.reduce((acc, curr) => ({...acc, ...curr}), {});
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.