Created
December 11, 2012 03:25
-
-
Save abhoopathy/4255691 to your computer and use it in GitHub Desktop.
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
/* | |
* Person class | |
*/ | |
function Person(name) { | |
this.name = name; | |
this.hi = function() { | |
console.log(this.name + " says hi!"); | |
}; | |
console.log('made a person'); | |
} | |
dave = new Person('dave'); | |
dave.hi(); | |
/* | |
* Person class, hi function | |
* added to prototype | |
*/ | |
function PersonB(name) { | |
this.name = name; | |
console.log('made a PersonB'); | |
} | |
PersonB.prototype = { | |
hi: function() { | |
console.log("" + this.name + " says hi!"); | |
} | |
}; | |
andy = new PersonB('andy'); | |
andy.hi(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment