Skip to content

Instantly share code, notes, and snippets.

@ahamed
Created August 9, 2022 07:44
Show Gist options
  • Select an option

  • Save ahamed/2098295ef1a47c35eb9e3a79d9fa0e90 to your computer and use it in GitHub Desktop.

Select an option

Save ahamed/2098295ef1a47c35eb9e3a79d9fa0e90 to your computer and use it in GitHub Desktop.
/**
* 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