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 JavaScript Loops, Arrays and Objects Tracking Data Using Objects Review Object Basics

Andrei Li
Andrei Li
34,486 Points

What is a literal? I red that the value of the literal cannot be changed but we change every time by assigning new value

What is a literal then? How do we change it? If we can. What does it mean when we assign variable a new value. Is that changing the value of the literal?

1 Answer

Andrey Misikhin
Andrey Misikhin
16,529 Points

Object literal is a collection of key, values pairs. You may change this variables inside object or you can change object literal itself by assigning another object.

obj = {
    key_1: 'red',
    key_2: 'blue'
}

obj.key_1 = 'orange';

obj = {
    key_3: 'black',
    key_4: 'white'
}