C Conditionally Add a Property to an Object in Javascript March 25, 2023 1 Min Read 0 46 let displayAge = true let user = { name: Olusola, ...(displayAge && { age: 10 }) } Don’t forget to share! Categorized in: JavaScriptWeb Dev Share Article: