Created
November 17, 2011 21:43
-
-
Save emkay/1374629 to your computer and use it in GitHub Desktop.
Inheritance
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
| // use Person as a constructor | |
| function Person(name, age) { | |
| this.name = name; | |
| this.age = age; | |
| } | |
| var student = new Person('mike', 29); | |
| Person.prototype.sayHello = function () { | |
| alert('Hello my name is ' + this.name); | |
| }; | |
| console.log(student); | |
| student.sayHello(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment