JavaScript Inheritance
Inheritance allows us to define a class that takes all the functionality from a parent class and allows us to add more. It is a core principle of Object-Oriented Programming (OOP), promoting DRY (Don't Repeat Yourself) code.
The `extends` Keyword
To create a class inheritance, use the extends keyword. A class created with a class inheritance inherits all the methods from another class.
The `super()` Method
The super() method refers to the parent class. By calling the super() method in the constructor method, we call the parent's constructor method and gets access to the parent's properties and methods. Important: You must call super() before you can use this in the subclass constructor.
Method Overriding
If a child class has a method with the exact same name as a method in its parent class, the child's method takes precedence when called on instances of the child class. This is known as overriding.
Prototypal Inheritance Under The Hood+
Remember that ES6 classes are mostly syntactic sugar over JavaScript's existing prototype-based inheritance. The extends keyword sets up the prototype chain automatically. Dog.prototype inherits from Animal.prototype.
