ES6 Classes
by Joshua McNeese
Babel + JSX
class Person {
constructor(name) {
this.name = name;
}
greet() {
console.log('Hi, my name is ' + this.name);
}
}
class Student extends Person {
constructor(name, subject) {
super(name);
this.subject = subject;
}
greet() {
super.greet();
console.log('I am studying ' + this.subject);
}
}
var student = new Student('Jane', 'Physics');
console.log(student.greet());
console.log(student instanceof Student);
console.log(student instanceof Person);