Ajax-loader-large-white
Introduction to Objects I
Constructors in Review

Constructors are a way to make objects with the keyword new. The most basic constructor is the Object constructor, which will make an object with no methods or properties.

For more complicated objects we can make our own constructors and put in whatever properties and methods we want.

Check out our example to the right to see objects in action. Our Rabbit constructor defines an adjective property and a describeMyself method.

Recall how these kind of custom constructors are important because they allow us to easily make many similar objects.

Instructions

Create a new object rabbit1 with the adjective "fluffy", a new object rabbit2 with the adjective "happy", and a new object rabbit3 with the adjective "sleepy".

Use the method describeMyself to print out in the console a sentence about each object you just created!

?
Stuck? Get a hint! Hint
Get live, fast support from Codecademy Advisors when you get stuck. Learn more.

To create an object using the rabbit constructor, we use the syntax:

var objectName = new constructorName(value for each property);

And to call the method, we use the syntax:

objectName.methodName( );

script.js