Last active
October 4, 2019 17:32
-
-
Save NyaGarcia/c4da92ef49936f35ab12b85a7b2bf6fb to your computer and use it in GitHub Desktop.
Removing several object properties with the rest parameter
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
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