Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@alexeyraspopov
Last active September 3, 2019 22:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexeyraspopov/d37de13367238c03e19039c846e6147c to your computer and use it in GitHub Desktop.
Save alexeyraspopov/d37de13367238c03e19039c846e6147c to your computer and use it in GitHub Desktop.
/**
* Usage
* function Base() {}
* Base.prototype. // anything
*
* let Child = Base.extend({ prototype }, { static });
* let instance = new Child();
*/
function extend(props, statics) {
let parent = this;
function Child() {
parent.apply(this, arguments);
}
Child.prototype = Object.assign(Object.create(parent.prototype), props);
Child.prototype.constructor = Child;
Object.assign(Child, statics);
return Child;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment