Skip to content

Instantly share code, notes, and snippets.

@jportella93
Created May 31, 2019 08:16
Show Gist options
  • Save jportella93/2189bbdeb4e764d0c5ccffb246e3e426 to your computer and use it in GitHub Desktop.
Save jportella93/2189bbdeb4e764d0c5ccffb246e3e426 to your computer and use it in GitHub Desktop.
Conditionally add property to an object JavaScript ES6
const a = {
...(someCondition && {b: 5})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment