Skip to content

Instantly share code, notes, and snippets.

@Storyyeller
Created December 29, 2017 04:24
Show Gist options
  • Save Storyyeller/69e7a3da840a64389b63f07e9ebf087b to your computer and use it in GitHub Desktop.
Save Storyyeller/69e7a3da840a64389b63f07e9ebf087b to your computer and use it in GitHub Desktop.
function Child(...args) {
const {constructor} = Object.getPrototypeOf(homeObject);
const $this = Reflect.construct(constructor, args);
// initialize subclass properties
$this.x = 43;
return $this;
}
Object.setPrototypeOf(Child, Base);
Object.setPrototypeOf(Child.prototype, Base.prototype);
const homeObject = Child.prototype;
const obj = new Child('some', 'args', 'for the superclass ctor');
console.log(obj.x); // 43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment