make an object by destructuring another code example

Example 1: how to use object destructuring to spread part of an object into another

how to use object destructuring to spread part of an object into another

Example 2: 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