Skip to content

Instantly share code, notes, and snippets.

@ksimons
Created January 16, 2014 10:21
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 ksimons/8452658 to your computer and use it in GitHub Desktop.
Save ksimons/8452658 to your computer and use it in GitHub Desktop.
function Foo(val) {
this.value = val;
this.increment = function() {
this.value++;
}
}
var f = new Foo(11);
f.increment();
console.log(f.value);
function Bar(val) {
this.value = val;
}
Bar.prototype.increment = function() {
this.value++;
}
var b = new Bar(22);
b.increment();
console.log(b.value);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment