Last active
February 24, 2021 23:55
-
-
Save borisStanojevic/c7b76a33477a7fdbb929fef94de45c9e to your computer and use it in GitHub Desktop.
Add property on an object conditionally
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 someCondition = 9 % 2 !== 0; | |
const someObject = { | |
standardProperty: "X", | |
...(someCondition && { conditionalProperty: "Y" }) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment