Let’s learn about another exciting concept which is what happens when you make objects inside another object. You'll also learn about a new kind of loop that you can use with objects.
So you just saw nested objects, where one object resides inside another object and how to access the keys of the nested object.
You also saw how to traverse objects like arrays using for..in loop. The syntax for..in loop is:
for (variable in objectName) { // code }
Let’s also learn how to modify an object. After all, what’s the use of data if you can't modify it when required?
You just learnt that to update the value of an object in javascript. There are two possible ways to do it.
var book = {name: 'Bible'}
In the above object, you can change the book name to Gita by simply doing:
book.name = 'Gita';
var book = {name: 'Bible'}
book.religion = 'Christianity';