Learning about ES6 destructuring is still new to me. I have encountered a scenario where I need to extract specific values from a nested object within an object.
For instance -
z = {g: 1, h: 2, i: {d1:5, d2:6, d3:7}}
When attempting to destructure with:
let { g, i : {d1, d3}, ...less } = z
The less
variable excludes d2
and only contains h
.
I am trying to find a way to achieve the desired result of:
less = {h, i : {d2}}