Last active
December 14, 2015 15:59
-
-
Save daniellmb/5111670 to your computer and use it in GitHub Desktop.
Classic "Holy Grail" inheritance pattern using an immediate function to store the proxy.
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
var inherit = (function () { | |
var proxy = function () {}; | |
return function (child, parent) { | |
proxy.prototype = parent.prototype; | |
child.prototype = new proxy(); | |
child._super = parent.prototype; | |
child.prototype.constructor = child; | |
} | |
}()); | |
//example use | |
//inherit(Child, Parent); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment