Skip to content

Instantly share code, notes, and snippets.

@ericelliott
Last active September 2, 2019 02:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ericelliott/15fc6c31ebaf41a6048d9ceadc985d2d to your computer and use it in GitHub Desktop.
Save ericelliott/15fc6c31ebaf41a6048d9ceadc985d2d to your computer and use it in GitHub Desktop.
Class inheritance demo 2 (not recommended)
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