Earlier in this chapter, we saw how difficult it was to implement inheritance hierarchies in functions. Therefore, ES6 aims to make it easy by introducing the extends clause and the super keyword for classes.
By using the extends clause, a class can inherit static and non-static properties from another constructor (which may or may not be defined using a class).
The super keyword is used in two ways:
- It's used in a class constructor method to call the parent constructor
- When used inside the methods of a class, it references the static and non-static methods of the parent constructor
Here is an example to demonstrate how to implement an inheritance hierarchy in constructors using the extends clause, and ...