Last active
September 2, 2019 02:23
-
-
Save ericelliott/15fc6c31ebaf41a6048d9ceadc985d2d to your computer and use it in GitHub Desktop.
Class inheritance demo 2 (not recommended)
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
class Teacher extends User { | |
constructor (options) { | |
super(options); | |
this.lessons = []; | |
} | |
createLesson (lesson) { | |
const { name } = lesson; | |
this.lessons.push(lesson); | |
console.log(`${ this.name } created lesson: ${ name }`); | |
} | |
} | |
const jafar = new Teacher({ | |
name: 'Jafar' | |
}); | |
jafar.login(); // "Jafar logged in." | |
jafar.createLesson({ | |
name: 'LearnRX' | |
}); // "Jafar created lesson: LearnRX" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment