Javascript optional properties
6 June 2023
javascript
const obj = {
...(true && { dogs: "woof" }),
...(false && { cats: "meow" }),
};
Neat and concise code for optional properties in an object declaration without using if
statements.