Created
September 11, 2012 20:12
-
-
Save jwmcpeak/3701666 to your computer and use it in GitHub Desktop.
JS Inheritence
This file contains 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
var Person = function(firstName, lastName) { | |
this.firstName = firstName; | |
this.lastName = lastName; | |
}; | |
Person.prototype.sayHi = function() { | |
return "Hello there!"; | |
}; | |
var Student = function(firstName, lastName, matriculatoryStatus) { | |
Person.call(this, firstName, lastName); | |
this.matriculatoryStatus = matriculatoryStatus; | |
}; | |
Student.prototype = Object.create(Person.prototype); | |
Student.prototype.sayHiToTeacher = function() { | |
return "Hi, teacher!"; | |
}; | |
var student = new Student("John", "Doe", "Freshman"); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment