Skip to content

Instantly share code, notes, and snippets.

@jonathantneal
Last active September 13, 2019 15:24
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 jonathantneal/f2d31c65abeaf8e5ff1bc589dd3d1219 to your computer and use it in GitHub Desktop.
Save jonathantneal/f2d31c65abeaf8e5ff1bc589dd3d1219 to your computer and use it in GitHub Desktop.
_extends: Extend a class with a super class
// 128/122 byte/gzip
/** Extend a class with a super class
* @param {Function} Class - class inheriting from the super class
* @param {Function} Super - super class inherited by the class
* @example <caption>Yayay extends Array</caption>
* function Yaray() {}
* _extends(Yaray, Array)
*/
function _extends(Class, Super) {
Class.prototype = Object.create(
(Class.__proto__ = Super).prototype,
{
constructor: {
configurable: true,
value: Class,
writable: true
}
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment