Nested objects
It's possible to have an object inside another object. In the example we have object
boyfriend
inside
cat
object
let 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
by Valeri Tandilashvili
4 years ago
JavaScript
objects
2
Pro tip: use ```triple backticks around text``` to write in code fences