Skip to content

Instantly share code, notes, and snippets.

@trivektor
Created November 11, 2011 18:13
Show Gist options
  • Select an option

  • Save trivektor/1358735 to your computer and use it in GitHub Desktop.

Select an option

Save trivektor/1358735 to your computer and use it in GitHub Desktop.
Exercise for JS Master Class (OOP)
function Person(name) {
this.name = name;
}
Person.prototype.getName = function() {
return this.name;
}
var thomas = new Person('Thomas');
var amy = new Person('Amy');
thomas.name
thomas.getName();
thomas.getName = function() {
return 'Amy'
}
thomas.getName.call(amy) //also works
thomas.getName();
delete Person.prototype.getName
console.log('getName' in Person.prototype)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment