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 Create an Object Literal

Abhijit Das
Abhijit Das
5,022 Points

what would happen if I used "const" keyword instead of "let?"

Hello everybody..what would happen if I used "const" keyword instead of "let"?

2 Answers

Jesus Mendoza
Jesus Mendoza
23,288 Points

The only thing that would happen is that you need to assign it a value from the beginning and its value can't be reasigned, however, if you have an array or an object assigned to a const, you can still change their properties

Vasanth Baskaran
Vasanth Baskaran
4,333 Points

After first initialization , if you try to modify the value in it error will be thrown which can be viewed in console.

In case of Array / Objects you can modify its properties or add / remove items in it. But it will throw error if you are assigning new array or objects to it.