Created
March 16, 2016 09:39
-
-
Save akushnikov/8812c65466d01603bb16 to your computer and use it in GitHub Desktop.
ES6 class system
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 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