destructure two objects to one variable code example
Example: how to destructure complex objects
const sampleState = {
name: “Michael”,
age: 36,
location: {
state: “OK”,
city: “Edmond”,
postal: “73012”
},
relatives: {
wife: {
name: “Shelley”
}
}
}
const { age, location: { city, state }, relatives: { wife: { name } } } = sampleState