Script Preparation code:
x
 
window.object1 = {};
window.object2 = {};
function makeid() {
  var text = "";
  var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  for (var i = 0; i < 5; i++)
    text += possible.charAt(Math.floor(Math.random() * possible.length));
  return text;
};
function populate(object) {
  for (let i = 0; i < 100; i++) {
    object[makeid()] = makeid();
  }
};
populate(object1);
populate(object2);
Tests:
  • Object.assign two objects

     
    let object7 = Object.assign({}, object1);
    object7 = Object.assign(object7, object2);
  • Spread two objects

     
    const object7 = Object.assign({}, object1);
    const object8 = {...object7, ...object2};
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Object.assign two objects
    Spread two objects

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 months ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Chrome 131 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
Object.assign two objects 47612.7 Ops/sec
Spread two objects 44886.8 Ops/sec