Skip to content

Instantly share code, notes, and snippets.

@kuanhsuh
Created October 4, 2018 08:59
Show Gist options
  • Save kuanhsuh/04c50c10b0a12e6038e57124a8728ebf to your computer and use it in GitHub Desktop.
Save kuanhsuh/04c50c10b0a12e6038e57124a8728ebf to your computer and use it in GitHub Desktop.
// Nesting
// Give Variable a new name
const phone = {
type: 'iphone xsmax',
ssd: '128GB'
}
const {type} = phone
const {type: model} = phone
console.log(type)
console.log(model)
const order = {
data: {
item: "Macbook 13",
specs: {
ram: 16,
ssd: "1TB"
},
status: "已送出"
}
}
const {data: { item }} = order
const {data: { item: computer }} = order
const { data: { specs: { ssd }}} = order
console.log(item)
console.log(computer)
console.log(ssd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment