Skip to content

Instantly share code, notes, and snippets.

@NyaGarcia
Last active October 4, 2019 17:32
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 NyaGarcia/c4da92ef49936f35ab12b85a7b2bf6fb to your computer and use it in GitHub Desktop.
Save NyaGarcia/c4da92ef49936f35ab12b85a7b2bf6fb to your computer and use it in GitHub Desktop.
Removing several object properties with the rest parameter
const pokemon = {
useless: 'Useless property',
id: 1,
name: 'Squirtle',
useless2: 'Another useless prop',
type: 'Water'
};
// Removing both useless and useless2 properties:
({ id, useless, useless2, ...newPokemon } = pokemon);
console.log(newPokemon); // Result: { name: 'Squirtle', type: 'Water' }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment