Skip to content

Instantly share code, notes, and snippets.

@leonkorteweg
Created July 14, 2016 05:20
Show Gist options
  • Save leonkorteweg/84677caafc823453aa28f745d9494846 to your computer and use it in GitHub Desktop.
Save leonkorteweg/84677caafc823453aa28f745d9494846 to your computer and use it in GitHub Desktop.
Inheritance in JS
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