Skip to content

Instantly share code, notes, and snippets.

@andreasonny83
Last active March 19, 2019 12:09
Show Gist options
  • Save andreasonny83/24b5237dd33a570f01f4a2aeb7683a75 to your computer and use it in GitHub Desktop.
Save andreasonny83/24b5237dd33a570f01f4a2aeb7683a75 to your computer and use it in GitHub Desktop.
Conditional Object key
// Conditional value
const a = {
...(someCondition && {b: 5})
}
// Remove key from object
const postData = {
token: 'secret-token',
publicKey: 'public is safe',
somethingElse: true,
};
const a = {
...(({token, ...rest} = postData) => (rest))(),
}
/**
a: {
publicKey: 'public is safe',
somethingElse: true,
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment