Skip to content

Instantly share code, notes, and snippets.

@alperg
Created October 17, 2019 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alperg/a084e6ff1e01368acf0a82d082aae5da to your computer and use it in GitHub Desktop.
Save alperg/a084e6ff1e01368acf0a82d082aae5da to your computer and use it in GitHub Desktop.
Exclude object props
// 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