Understanding JavaScript Class Inheritance, Inherit from Parent Class, Inheritance IV, Codecademy JS

In this JavaScript lesson, we take a look at Understanding JavaScript Class Inheritance, Inherit from Parent Class, Inheritance IV, Codecademy JS. In it, we continue learning about Inheritance in JavaScript. We take a look at a parent class and a child class. We learn that our child class is able to inherit from a parent class. When a child class inherits from a parent class, it gets access to all the parent class’ properties and methods. We give a child class access to a parent class’ methods and properties using the extend keyword. We also learn that we are able to pass values into the constructor of our parent class, by using the super keyword. Using the super keyword allows us to pass in values from our child constructor to our parent constructor. Always running the super keyword first is important so that you can have access to “this”. Once you have created your child class, you can then create an instance of your child class. Once you do, you will have access to all the properties and methods in the instance you create. We are able to see an example of that in our lesson. We have our parent class, HospitalEmployee and we create a child class, Nurse. We then create an instance of our Nurse and see how we would access our parent properties and methods! Make sure to practice creating class instances to make sure you understand before moving on to the next lesson!