ES6 classes provide a syntactic sugar over JavaScript’s existing prototype-based inheritance.
Source Code
class Person {
constructor(name) {
this.name = name;
}
greet() {
console.log(`Hello, ${this.name}`);
}
}
let person = new Person('John');
person.greet(); // Hello, John