Created
June 29, 2022 13:28
-
-
Save PaulRosset/6cc2b03668939da8a7f101541621213f to your computer and use it in GitHub Desktop.
Conditionally add a property to an object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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