Created
December 29, 2017 04:24
-
-
Save Storyyeller/69e7a3da840a64389b63f07e9ebf087b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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