HTML Preparation code:
AخA
 
1
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Script Preparation code:
x
 
var x = null;
var testObjectArray = [{
    a: 1
}, {
    b: 1
}, {
    c: [1, 2, 3]
}, {
    d: "hello"
}, {
    e: "e",
    f: "f"
}];
var reduceMergeArrow = (objectArray) => objectArray.reduce(((accumulator, object) => Object.assign(accumulator, object)))
function reduceMerge(objectArray) {
  return objectArray.reduce(((accumulator, object) => Object.assign(accumulator, object)));
}
Tests:
  • lodash merge spread

     
    x = _.merge(...testObjectArray);
  • lodash merge loop

     
    x = {}
    for(const object in testObjectArray) {
      x = _.merge(x, object);
    }
  • reduce merge arrow

     
    x = reduceMergeArrow(testObjectArray);
  • reduce merge

     
    x = reduceMerge(testObjectArray);
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    lodash merge spread
    lodash merge loop
    reduce merge arrow
    reduce merge

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 10 months ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Chrome 126 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
lodash merge spread 1446674.5 Ops/sec
lodash merge loop 189624.9 Ops/sec
reduce merge arrow 2436103.0 Ops/sec
reduce merge 2473860.8 Ops/sec