Set class attributes on extends

by sas_sam

JavaScript

class A {
	constructor(options) {
  	this.a = 'a';
    let self = this;
    
    Object.keys(options).forEach((key) => {
    	self[key] = options[key];
    });
  }
}

class B extends A {
	constructor() {
  	super({
    	b: 'b',
      c: function() {},
      d: ko.observable(false)
    });
  }
}

const b = new B();

console.log(b);