This course will be retired on October 31, 2026.
Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Introducing ES2015!
You have completed Introducing ES2015!
Preview
Learn how to create new classes based off of an existing class.
Code snippets
class Student {
constructor({ name, age, interestLevel = 5 } = {} ) {
this.name = name;
this.age = age;
this.interestLevel = interestLevel;
this.grades = new Map;
}
}
Resources
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
In the previous video you learned
how to define a class of Student.
0:00
In this video I'll add new features to the
Student class by extending another class.
0:02
I'll show you how extending classes
can help keep your code modular and
0:07
easy to reason about.
0:10
And if you're following along,
go ahead and open the latest workspace for
0:12
this course.
0:15
In the file subclass.js,
I'm going to add new properties and
0:16
methods to the Student class by
extending this Person class.
0:20
As you can see, the Person class takes
three parameters, name, age, and eyeColor.
0:25
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up