Условно добавить участников в объект

const condition = true
const obj = Object.assign({}, condition ? {
  b: 5
} : null)
console.log(obj)
Prickly Partridge