if statement with object condition js code example
Example 1: js conditional object
const object = {
...bool && { foo: 2 },
}
Example 2: checking a condition in object javascript
{ id: 'some-id', ...(true && { optionalField: 'something'})}
const object = {
...bool && { foo: 2 },
}
{ id: 'some-id', ...(true && { optionalField: 'something'})}