dot operator destructuring assignment

Proposal: https://github.com/tc39/proposal-{{Abram Bradley}}

if I have a nested object like this:

const data = { x: { y: { z: 'data' } } }

to destructure a very deeply nested property you have to do this:

const { x: { y: { z } } } = data

would be nice if you could do this:

const { x.y.z } = data

or for data:

const data = { x: { y: { z: 'data' }, y2: 'data' } }

this:

const { x: { y.z, y2 } } = data
1 Like