Skip to content

Instantly share code, notes, and snippets.

@bishopgrutty
Created August 9, 2011 17:21
Show Gist options
  • Save bishopgrutty/1134637 to your computer and use it in GitHub Desktop.
Save bishopgrutty/1134637 to your computer and use it in GitHub Desktop.
//Step 1
var Person = function (name) {
this.name = name;
}
var thomas = new Person('Thomas');
var amy = new Person('Amy');
console.log("thomas.name: ",thomas.name);
//Step 2
Person.prototype.getName = function () {
return this.name;
}
console.log("thomas.getName(): ",thomas.getName());
//Step 3
console.log("thomas.getName.call(amy): ",thomas.getName.call(amy));
//Step 4
console.log("getName in Thomas: ",'getName' in thomas);
delete Person.prototype.getName;
console.log("getName in Thomas: ",'getName' in thomas);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment