Chave condicional js

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