1const condition = getCondition();
2const additionalCondition = getAdditionalCondition();
3
4const person = {
5 firstName: "Max",
6 ...(condition && { lastName: "" }),
7 ...(additionalCondition && { addition: "" }),
8};
1const trueCondition = true;const falseCondition = false;const obj = { ...(trueCondition && { dogs: "woof" }), ...(falseCondition && { cats: "meow" }),};// { dogs: 'woof' }