Skip to content

Instantly share code, notes, and snippets.

@PaulRosset
Created June 29, 2022 13:28
Show Gist options
  • Save PaulRosset/6cc2b03668939da8a7f101541621213f to your computer and use it in GitHub Desktop.
Save PaulRosset/6cc2b03668939da8a7f101541621213f to your computer and use it in GitHub Desktop.
Conditionally add a property to an object
const moreInfos = { info: "Please go to the desk." }
return {
address: "20B Rue Lafayette",
postcode: "75009",
...(moreInfos !== undefined && { moreInfos })
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment