Created
May 10, 2013 04:25
-
-
Save jeremyckahn/5552373 to your computer and use it in GitHub Desktop.
Proxy-based inheritance pattern in JavaScript.
This file contains hidden or 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
function inherit (child, parent) { | |
function proxy () {}; | |
proxy.prototype = parent.prototype; | |
child.prototype = new proxy(); | |
}; | |
function Parent () {} | |
function Child () {} | |
inherit(Child, Parent); | |
var child = new Child(); | |
console.log(child instanceof Child); // true | |
console.log(child instanceof Parent); // true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/kenkin360/Function.extend/blob/master/Function.extend.es5.js
https://github.com/kenkin360/Function.extend/blob/master/Function.extend.js