Created
October 17, 2019 15:49
-
-
Save alperg/a084e6ff1e01368acf0a82d082aae5da to your computer and use it in GitHub Desktop.
Exclude object props
This file contains 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
// Properties can be removed using destructuring in combination with the rest operator. | |
// Here password is destructured out (ignored) and the rest of the properties are returned as rest. | |
const noPassword = ({ password, ...rest }) => rest; | |
const user = { | |
id: 100, | |
name: 'Howard Moon', | |
password: 'Password!' | |
}; | |
noPassword(user); // { id: 100, name: 'Howard moon' } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment