Skip to content

Instantly share code, notes, and snippets.

@twhite96
Created November 24, 2022 05:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save twhite96/0eefc768d3d762ad64a82edbe08b8362 to your computer and use it in GitHub Desktop.
Save twhite96/0eefc768d3d762ad64a82edbe08b8362 to your computer and use it in GitHub Desktop.
Nested object destructuring
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