Last active
March 19, 2019 12:09
-
-
Save andreasonny83/24b5237dd33a570f01f4a2aeb7683a75 to your computer and use it in GitHub Desktop.
Conditional Object key
This file contains hidden or 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
// 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