Skip to content

Instantly share code, notes, and snippets.

@daniellmb
Last active December 14, 2015 15:59
Show Gist options
  • Save daniellmb/5111670 to your computer and use it in GitHub Desktop.
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.
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