boyfriend
inside cat
objectlet cat = {
name: 'Lucy',
age: 4,
meow() {
console.log('Meowwww');
},
boyfriend: {
name: 'Jack',
age: 5,
favoriteColors: ['Green', 'Yellow'],
meow() {
console.log('Meeoowwwwwwwwwwww');
},
}
}
Accessing nested object's attributes and methods:console.log(cat.boyfriend.name); // Jack
cat.boyfriend.meow(); // Meeoowwwwwwwwwwww