Inheritance in Classes
Introduction to inheritance in classes in JavaScript.
We'll cover the following...
In this lesson we will implement inheritance in classes.
Inheritance in classes
The underlying concept when utilizing inheritance is the same in both approaches: constructor functions and classes. However, the latter provides a cleaner syntax as well as new keywords. First, take a look at the expected hierarchy in a class-based approach for inheritance in the diagram below.
Use the extends
keyword to have all properties available from one class to another.
class childClassName extends parentClassName{
//body containing constructor and methods
}
First, write the child class followed by the extends
keyword, then the name of the parent class, which is upon which the child class is based and will ...