Skip to content

Instantly share code, notes, and snippets.

@wyattdanger
Created May 1, 2012 20:28
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 wyattdanger/2571117 to your computer and use it in GitHub Desktop.
Save wyattdanger/2571117 to your computer and use it in GitHub Desktop.
to give each instance of Bar it's own `a` property, rather than a shared `a` on the prototype
function Foo () {
this.a = [];
}
+function Bar () {
+ Foo.call(this);
+}
-function Bar () {}
Bar.prototype = new Foo();
Bar.prototype.constructor = Bar;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment