Skip to content

Instantly share code, notes, and snippets.

@Integralist
Forked from jeremyckahn/inherit-by-proxy.js
Last active December 20, 2015 01:09
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 Integralist/6046756 to your computer and use it in GitHub Desktop.
Save Integralist/6046756 to your computer and use it in GitHub Desktop.
JavaScript: inheritance by proxy
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