Give an example and explain the main difference between ES6 class and ES5 function constructors?
The main difference between these two is when you are using inheritance. It is much more complicated using inheritance in ES5, while the ES6 version is simple and easy to remember.
ES6 Class:
class Person {
constructor(name) {
this.name = name;
}
}
ES5 function constructor:
function Person(name) {
this.name = name;
}
BY Best Interview Question ON 24 Aug 2022