1

I have the following block of borrowed code in one of my JS projects:

return Promise.all(accessoryGetMethods)
.then(systemAccessories => {
  const [partitions, sensors, lights, locks] = systemAccessories
  return {
    id: res.data.id,
    attributes: res.data.attributes,
    partitions: partitions.map(p => p.data),
    sensors: typeof sensors != 'undefined' ? sensors.data : [],
    lights: typeof lights != 'undefined' ? lights.data : [],
    locks: typeof locks != 'undefined' ? locks.data : [],
    relationships: rels
  }
})

In particular, what kind of assignment pattern is the line:

 const [partitions, sensors, lights, locks] = systemAccessories
jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Mike Kormendy
  • 3,389
  • 2
  • 24
  • 21

0 Answers0