Skip to content

Instantly share code, notes, and snippets.

@MostlyFocusedMike
Last active June 28, 2018 02:37
Show Gist options
  • Save MostlyFocusedMike/4f0a4f12ec37142e784d4d566b7a20c8 to your computer and use it in GitHub Desktop.
Save MostlyFocusedMike/4f0a4f12ec37142e784d4d566b7a20c8 to your computer and use it in GitHub Desktop.
let user = {
paid: true,
attributes: {
id: 43020233,
description: {
name: "tom",
age: 23,
level: 2
}
}
}
// instead of this:
// let description = user.attributes.description
// name = description.name
// age = description.age
// level = description.level
// we can do this:
let {name, age, level} = user.attributes.description
console.log(name)
// nice
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment