Skip to content

Instantly share code, notes, and snippets.

@javascripto
Last active September 1, 2019 18:41
Show Gist options
  • Select an option

  • Save javascripto/9c9c1649364cdada50af826dfe18940e to your computer and use it in GitHub Desktop.

Select an option

Save javascripto/9c9c1649364cdada50af826dfe18940e to your computer and use it in GitHub Desktop.
Array.prototype.pluck = function(...keys) {
return this.map(item => keys.reduce((acc, key) =>
(key in item) && (acc[key] = item[key]) ? acc : acc, {}));
}
Array.prototype.pluck = function(...keys) {
return this.map(item => JSON.parse(JSON.stringify(item, [...keys])));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment