Changing Properties
Update an object.
Swapping Treasures 🔄
What if your dog has a birthday 🎂? Its age should change!
Good news: we can change a treasure inside an object any time we want.
Use the Dot and Equals 🟰
To change a treasure, use the dot to point at it, then = to give it a new value.
Like saying: dog DOT age, you are now 5!
let dog = { name: 'Rex', age: 4 }
dog.age = 5
console.log(dog.age)All lessons in this course
- What Is an Object?
- Reading Properties
- Changing Properties
- A Pet Object