checking a condition in object javascript

JavaScript
{  id: 'some-id',  ...(true && { optionalField: 'something'})}
Source

Also in JavaScript: