let myProperty = { id: 1, name: 'one' } const myObject = { ...myProperty && { propName: myProperty } }; console.log('myObject', myObject)