Skip to content

Instantly share code, notes, and snippets.

@abhoopathy
Created December 11, 2012 03:25
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 abhoopathy/4255691 to your computer and use it in GitHub Desktop.
Save abhoopathy/4255691 to your computer and use it in GitHub Desktop.
/*
* Person class
*/
function Person(name) {
this.name = name;
this.hi = function() {
console.log(this.name + " says hi!");
};
console.log('made a person');
}
dave = new Person('dave');
dave.hi();
/*
* Person class, hi function
* added to prototype
*/
function PersonB(name) {
this.name = name;
console.log('made a PersonB');
}
PersonB.prototype = {
hi: function() {
console.log("" + this.name + " says hi!");
}
};
andy = new PersonB('andy');
andy.hi();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment