Last active
September 13, 2019 15:24
-
-
Save jonathantneal/f2d31c65abeaf8e5ff1bc589dd3d1219 to your computer and use it in GitHub Desktop.
_extends: Extend a class with a super class
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
// 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