Bummer! You have been redirected as the page you requested could not be found.
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 Object-Oriented JavaScript!
You have completed Object-Oriented JavaScript!
Preview
Learn how to instantiate new objects from classes.
This video doesn't have any notes.
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
Creating an instance of a class is really
easy, and you might have seen this syntax
0:00
before, perhaps when using the JavaScript
date object, or when creating a new array.
0:01
First, declare a variable
that will hold your object,
0:05
set it equal to the keyword new,
followed by the class name.
0:08
Make sure the first letter of
the class name is capitalized,
0:11
just like when we declared the Pet class.
0:15
And remember, we'll want to pass in
the correct parameters, age, animal, and
0:17
breed, to the constructor
method inside the class.
0:21
In this example,
those values will be dog, 1, and pug.
0:24
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