Agregue condicionalmente los miembros a un objeto
const condition = true
const obj = Object.assign({}, condition ? {
b: 5
} : null)
console.log(obj)
Prickly Partridge
const condition = true
const obj = Object.assign({}, condition ? {
b: 5
} : null)
console.log(obj)