Created
November 24, 2022 05:09
-
-
Save twhite96/0eefc768d3d762ad64a82edbe08b8362 to your computer and use it in GitHub Desktop.
Nested object destructuring
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cats = { | |
one: { | |
name: "Molly", | |
owner: "Fred Larkin", | |
color: "Brown", | |
age: 10, | |
kittens: 0 | |
}, | |
two: { | |
name: "Bob", | |
owner: "Sally Doe", | |
color: "Black", | |
age: 2, | |
kittens: 0 | |
}, | |
three: { | |
name: "Poppy", | |
owner: "Alice Green", | |
color: "Tabby", | |
age: 3, | |
kittens: 2 | |
} | |
}; | |
const { two: { name } } = cats; | |
console.log(name);//Returns: Bob |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment