Skip to content

Instantly share code, notes, and snippets.

@joelnet
Created March 18, 2019 00:21
Show Gist options
  • Save joelnet/80ebebbd69b3defa11b9d0f1020e87ec to your computer and use it in GitHub Desktop.
Save joelnet/80ebebbd69b3defa11b9d0f1020e87ec to your computer and use it in GitHub Desktop.
const user = { id: 100, name: 'Howard Moon' }
const password = 'Password!'
const userWithPassword = {
...user,
id: 100,
...(password && { password })
}
userWithPassword //=> { id: 100, name: 'Howard Moon', password: 'Password!' }
@joelnet
Copy link
Author

joelnet commented Mar 18, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment