Classes in ES6
1 min readOct 7, 2015
In ES6 JavaScript programmers will be able to build their applications using object-oriented class-based approach.
class Greeting {
msg;
constructor(msg){
this.msg = msg;
}
greet(){
return `Hello ${this.msg}`;
}
}class Person extends Greeting{
name;
constructor(name, msg){
super(msg);
this.name = name;
}
personGreeting(){
console.log(`${this.name} said, ${super.greet()}`);
}}
let sam = new Person('Sam', 'World');
sam.personGreeting();
The above example shows how to use classes in ES6 and use inheritance (extends).