1

I know you can do object destructuring in ES6 but I was wondering if there is a clever solution for constructor destructuring so I can skip the manual assignment like below and instead do something like the hypothetical scenario. I know it is dangerous and unreliable to accept everything in constructor, but just curious.

// Hypothetical 
constructor(... args){
 object.assign(this,...args);
}

constructor(pieceName,pieceImage,dataAttribute,numeric,ascii){
        this.pieceName = piecename; 
        this.pieceImage = pieceImage; 
        this.dataAttribu

}
Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122
Yasin Yaqoobi
  • 1,888
  • 3
  • 27
  • 38

0 Answers0