Created
July 14, 2016 05:20
-
-
Save leonkorteweg/84677caafc823453aa28f745d9494846 to your computer and use it in GitHub Desktop.
Inheritance in JS
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(firstName, lastName) { | |
this.firstName = firstName; | |
this.lastName = lastName; | |
} | |
Person.prototype.fullName = function() { | |
return this.firstName + " " + this.lastName; | |
}; | |
function Teacher(roomNumber) { | |
Person.call(this, firstName, lastName); | |
this.roomNumber = roomNumber; | |
} | |
Teacher.prototype = Object.create(Person.prototype); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment