Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Object-Oriented JavaScript Object Basics Changing and Adding Properties

How does this work if ernie is labeled const? Wouldn't that make the object immutable?

How does this work if ernie is labeled const? Wouldn't that make the object immutable?

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there, Trenton! First, kudos on picking up on the const! But this makes the object immutable. The properties inside them are specific to that object. She touches on this in the first video around 0:38.

Properties are like object specific variables that store information.

You can change the values of the properties, but you cannot overwrite the entire object. For instance you couldn't later do this:

ernie = [1, 2, 3];

It won't allow for you to change the object itself, but the properties inside them (and even the methods) are like variables that are specific to that object.

Hope this helps! :sparkles:

Thanks for the explanation!