Run details:
Mozilla/5.0 (Android 10; Mobile; rv:81.0) Gecko/81.0 Firefox/81.0
Firefox Mobile 81
Android
Mobile
4 years ago
Test name Executions per second
Using the spread operator 2987527.8 Ops/sec
Using Object.assign 2712594.8 Ops/sec
Tests:
  • Using the spread operator

    AخA
     
    const firstObject = { sampleData: 'Hello world' }
    const secondObject = { moreData: 'foo bar' }
    const finalObject = {
        ...firstObject,
        ...secondObject
    };
  • Using Object.assign

     
    const firstObject = { sampleData: 'Hello world' }
    const secondObject = { moreData: 'foo bar' }
    const finalObject = Object.assign({}, firstObject, secondObject);