Created
February 25, 2014 05:34
-
-
Save alexmcpherson/9203303 to your computer and use it in GitHub Desktop.
Prototype sample code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Person(name) { | |
this.name = name; | |
} | |
Person.prototype.whoAmI = function() { | |
console.log(this.name); | |
} | |
var alex = new Person('alex'); | |
alex.whoAmI(); | |
alex.name; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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