is there a 1-step way to destructure object into 2 objects using some defined set of props.
For example, having initial object
const obj = {
prop1: "Prop1",
prop2: "Prop2",
prop3: "Prop3",
....
}
i'd like to do smth like:
const { firstObj: { prop1, prop2, prop3 }, secondObj: { ...rest }} = obj;
So far I have to do it in 2 steps like here Destructure to two separate variables:
- destructure obj prop1, prop2, prop3 and ...rest
- save {prop1, prop2, prop3 } as firstObj, {...rest} as secondObj