From the course: JavaScript: Classes

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Constructor and super usage

Constructor and super usage - JavaScript Tutorial

From the course: JavaScript: Classes

Constructor and super usage

- [Instructor] So we explore constructors and the super keyword in the introduction. So let's use them. So we're going to go back to our class car here and what we're going to do is extend that class into a brand new class called SUV. So let's go ahead and do that. So we're going to create the class SUV and this class extends the class car. So basically what we're going to do is leverage all the stuff that we've built in here. So we'll leverage doors, engine, and color into our new class. And the way to do that is first, you have to declare what you're going to use in this class, in the class SUV with the constructor. So we're going to do doors, engine, color, brand and then the method car stats. And then in order to use these elements or these properties from the previous class, this is where the super keyword comes into play. So we're going to do super and then we're going to add the elements of the class that were…

Contents