Skip to content

Instantly share code, notes, and snippets.

@akushnikov
Created March 16, 2016 09:39
Show Gist options
  • Save akushnikov/8812c65466d01603bb16 to your computer and use it in GitHub Desktop.
Save akushnikov/8812c65466d01603bb16 to your computer and use it in GitHub Desktop.
ES6 class system
class Human {
constructor(name) {
this.name = name;
}
introduce() {
console.log(`My name is ${this.name}`);
}
}
class Teacher extends Human {
constructor(name, subject) {
super(name);
this.subject = subject;
}
introduce() {
super.introduce();
console.log(`My subject is ${this.subject}`)
}
}
let human = new Human('Vladimir Putin');
human.introduce();
let teacher = new Teacher('Alice', 'History');
teacher.introduce();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment