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
As simple as that:
const { building1: { floor: floor1 },building2: { floor: floor2 }} = data;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.