Свойство условного объекта JS
const a = {
...(someCondition && {b: 5})
}
Defiant Dragonfly
const a = {
...(someCondition && {b: 5})
}
const condition = getCondition();
const additionalCondition = getAdditionalCondition();
const person = {
firstName: "Max",
...(condition && { lastName: "" }),
...(additionalCondition && { addition: "" }),
};
const object = {
...bool && { foo: 2 },
}