DEV Community

Discussion on: 10 Clean code examples (Javascript).

Collapse
 
ishwarm81238332 profile image
Ishwar More

But there is no b. keys are different and value is same (here a).

const { ['x']: a, ['y']: a } = foo; will not be possible

Thread Thread
 
jamesthomson profile image
James Thomson

It's re-assigning the value. ['y']: b assigns the value of y to b so you can now access it as b.