Arguments decontruction-reconstruction demonstration

Practical example of returning customized objects depending on incoming arguments

by SSRRDD

JavaScript

class myClass
{ // if the initialization call has at least one argument, the first object is created,
  // is so arguments are passed, then the second object is created
  constructor({a = 'default a value', b = 'default b value', c = 'default c value'} = {a:'default option a', b:'default option b', c:'default option c'})
  {
    this.a = a;
    this.b = b;
    this.c = c;
  }
}
var v = new myClass({a:'a value', b: 'b value'});
console.log(v);
var w = new myClass();
console.log(w);