Skip to content

Instantly share code, notes, and snippets.

@alexmcpherson
Created February 25, 2014 05:34
Show Gist options
  • Save alexmcpherson/9203303 to your computer and use it in GitHub Desktop.
Save alexmcpherson/9203303 to your computer and use it in GitHub Desktop.
Prototype sample code
function Person(name) {
this.name = name;
}
Person.prototype.whoAmI = function() {
console.log(this.name);
}
var alex = new Person('alex');
alex.whoAmI();
alex.name;
function MyClass() {}
MyClass.prototype.testFunction = function() {
console.log("I'm from the prototype");
}
var mc = new MyClass()
mc.testFunction()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment