- [Instructor] So we explored constructors
and the super keyword in the introduction,
so let's use them.
So let's go back to our file, the app.js file here,
and the first thing we'll do is to make sure
that we extend a new class.
So let's go ahead and do that.
We'll first create a class called SUV,
like the example we mentioned in the previous video,
and we'll extend Car.
And then what we'll do is use constructors.
So this is how constructor is used.
So in this constructor we'll pass the values
that we want this class to have.
So we'll do engine
let's do doors plural,
color, which are the same as the original one here.
So doors, engine, and colors.
So we're extending that class into this new one here.
And then we'll create new properties
for this particular class.
So brand, and then we'll have a function called carStats.
And then let's continue with initializing that constructor.
So in order to be able to use those three
from the class that we're extending,
so the doors, engine, and color,
we need to use the keyword super.
And this is what super is used for.
So basically what it does,
it creates a new object and pulls all the stuff that we have
in the constructor from the initial class, Car.
So we need again to pass doors,
engine, and color,
and also carStats that we have as a function here.
Now we have all these things that are
available in this particular class year,
so the SUV class.
And then what we can do is create
specific properties for the SUV.
So for example we could do the brand,
which equals brand.
And we could also assign some values.
So we don't need to pass some values,
we can actually create them when
the new object of SUV is created.
So for example, we could do something like wheels.
So that car has obviously four wheels.
And then this car as an ac,
so we make it as a Boolean true.
And we can also create a function specific to the SUV.
So we could do something like myBrand.
And then return in the console log
and let's do template strings for this one.
So let's do this SUV is a
and then we'll pass the value from this brand.
So now that we have our SUV class,
let's also create a CX5.
So the Mazda CX5 with an SUV class
as opposed to a new Car class.
So let's do that.
So as opposed to Car we'll switch this to an SUV,
and we're still passing four doors.
I'm not sure it has a V6 'cause
I'm not an automobile expert.
But I will just type this for now.
And then we need to also pass a brand.
So this is a Mazda.
So if we saved this and go back to our Sandbox here,
we can see that now we have a class called SUV
and we have all these properties
that have been created for us.
So we have an ac, brand, color, doors, engine, and wheels.
And we've been able to pass all this
because we've leveraged the class car
and extended it by creating a new class called SUV
and then we've assigned specific things for the SUV class.
So one thing that we could do also is use the method
that's specific to SUV.
So we could do something like,
CX5 and then call my brand.
And if we go back here we have a message
that says This SUV is a mazda.
So in short this is how you do super and constructors
when you create brand new class extended from other classes.
Let's move on.