Kunci objek bersyarat JS

const object = {
  ...bool && { foo: 2 },
}
Lucas Charvolin