Skip to content

Instantly share code, notes, and snippets.

@meagar
Created September 9, 2011 17:09
Show Gist options
  • Save meagar/1206764 to your computer and use it in GitHub Desktop.
Save meagar/1206764 to your computer and use it in GitHub Desktop.
var Person = function(name) {
this.name = name;
};
// Part 2
Person.prototype.getName = function() {
return this.name;
};
var thomas = new Person('Thomas');
var amy = new Person('Amy');
console.info(thomas.name) // --> "Thomas"
// Part 3
console.info(thomas.getName.call(amy)); // Amy
// Part 4
delete Person.prototype.getName;
console.info(thomas.getName); // undefined
console.info(amy.getName); // undefined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment