Created
October 6, 2019 16:05
-
-
Save NyaGarcia/2ba32b03d032c97d8c43ef1035b4aee6 to your computer and use it in GitHub Desktop.
Removing an object property dynamically with the rest parameter - ES6 version
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', | |
type: 'Water' | |
}; | |
const remove = (property, { [property]: value, ...newObject }) => newObject; | |
console.log(remove('useless', pokemon)); // Result: { id: 1, name: 'Squirtle', type: 'Water' } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment