Clave condicional JS

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