Skip to content

Instantly share code, notes, and snippets.

@vjeux
Created June 29, 2014 13:33
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 vjeux/24bb600d563e6b0e68c6 to your computer and use it in GitHub Desktop.
Save vjeux/24bb600d563e6b0e68c6 to your computer and use it in GitHub Desktop.
var SomeClassClosure = function() {
this.method = function() {}
}
new SomeClassClosure
// {method: fnA()}
new SomeClassClosure
// {method: fnB()} // a new fn is allocated each time
var SomeClassPrototype = function() {}
SomeClassPrototype.prototype.method = function() {}
new SomeClassPrototype
// {__proto__: SomeClassPrototype.prototype}
new SomeClassPrototype
// {__proto__: SomeClassPrototype.prototype}
// method is shared between the two instances
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment