You can build objects from truthy and falsy values, something like:

const obj = {
  ...(true) && { someprop: 42 },
  ...(false) && { nonprop: "foo" },
  ...({}) && { tricky: "hello" },
}
console.log(obj); // {someprop: 42, tricky: 'hello'}