Created
August 9, 2022 07:44
-
-
Save ahamed/2098295ef1a47c35eb9e3a79d9fa0e90 to your computer and use it in GitHub Desktop.
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
| /** | |
| * Remove some properties from an object, | |
| * and work with other properties. | |
| * | |
| * You can use destructuring and ...rest operator for gaining this result. | |
| * | |
| * @author Sajeeb Ahamed <sajeeb07ahamed@gmail.com> | |
| */ | |
| const store = { | |
| id: '123', | |
| alias: '123', | |
| name: 'John Doe', | |
| age: 24, | |
| gender: 'male', | |
| }; | |
| const { id, alias, ...data } = store; | |
| // If you are using eslint and it complains about no-unused-vars | |
| // Then you can rename the unused variables with underscore(s). | |
| // const { id: _, alias: __, ...data } = store; | |
| console.log(data); // {name: 'John Doe', age: 24, gender: 'male'}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment