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
Add properties to the class blueprint using the constructor method.
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
objects of this class type
will have available to them.
0:00
The object literals in the pets.js
file have three properties,
0:00
animal, age, and breed.
0:05
I think you'll agree that these
are appropriate to use in this pet
0:07
class as well.
0:10
If we were writing a Dog class instead,
0:12
the animal property would be pretty
redundant, so we could leave that one out.
0:14
But since we're writing a Pet class,
it's important to keep.
0:17
To include a property in
a constructor method,
0:21
you write the word this, followed by a
dot, followed by the name of the property.
0:23
If you recall, when we want to add
a property to an object literal,
0:28
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