Reputation: 37
I want to destructure the values from the same object inside multiple objects.
const data ={
building1: {
floor: 'cnt',
}
building2: {
floor: 'bcnt'
}
}
Is there any way to destructure in single line as floor1, floor2
Upvotes: 1
Views: 88
Reputation: 94
As simple as that:
const { building1: { floor: floor1 },building2: { floor: floor2 }} = data;
Upvotes: 5