0

I have the following object:

const randomObject = {
  propertyA: someValueA,
  propertyB: someValueB,
  nestedObj:{
    propertyA: someOtherValueA,
    propertyX: someValueX
  }
};

Now if I destructure the randomObject using const{propertyA} = randomObject then I get the value someValueA but I want the propertyA to be someOtherValueA from nestedObject inside randomObject. The other answers on StackOverflow have a different name of the property in the child object and not the exact same parent-child name.

Is there any way to achieve this? Any help is highly appreciated.

Manav
  • 109
  • 1
  • 4

0 Answers0