Test name | Executions per second |
---|---|
deconstruct | 331103.6 Ops/sec |
Object.assign | 278221.2 Ops/sec |
"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)
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)