Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36
Chrome 102
Windows
Desktop
2 years ago
Test name Executions per second
deconstruct 331103.6 Ops/sec
Object.assign 278221.2 Ops/sec
Tests:
  • deconstruct

    AخA
     
    "use strict";
    class Box {
        constructor(params = {}) {
            var { x = 0, y = 0, height = 1, width = 1 } = params;
            this.x = x;
            this.y = y;
            this.height = height;
            this.width = width;
        }
    }
    const b = new Box({ x:3, y: 0, height: 23, width: 1});
    console.assert(b.x === 3)
  • Object.assign

     
    class Box {
      constructor(params = {}){
            this.x = 0;
            this.y = 0;
            this.height = 1;
            this.width = 1;
            Object.assign(this, params);
      }
    }
    const a = new Box({ x:3, y: 0, height: 23, width: 1});
    console.assert(a.x === 3)