destructure return object with new names 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