Skip to content

Instantly share code, notes, and snippets.

@borisStanojevic
Last active February 24, 2021 23:55
Show Gist options
  • Save borisStanojevic/c7b76a33477a7fdbb929fef94de45c9e to your computer and use it in GitHub Desktop.
Save borisStanojevic/c7b76a33477a7fdbb929fef94de45c9e to your computer and use it in GitHub Desktop.
Add property on an object conditionally
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