Script Preparation code:
x
 
var first = {
  foo: "string",
  bar: 42,
  baz: 100.56,
  quux: "another string",
  foobar: {
    one: "foo bar",
    two: "bar foo"
  },
  bazbaz: function (a, b) {
    return a * a % b + 100 / b;
  }
};
var second = {
  one: "x",
  two: "y",
  three: "z",
  x: "one",
  y: "two",
  z: "three",
  foo: "string 2",
  bar: 43
};
Tests:
  • Object assign

     
    const third_assign = Object.assign({}, first, second);
    return third_assign;
  • Object spread

     
    const third_spread = {
      ...first,
      ...second,
    };
    return third_spread;
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Object assign
    Object spread

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 4 years ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36
Chrome 84 on Windows
View result in a separate tab
Test name Executions per second
Object assign 772325.4 Ops/sec
Object spread 92813.4 Ops/sec