Skip to content

Instantly share code, notes, and snippets.

@alex-cory
Created January 15, 2019 00:51
Show Gist options
  • Save alex-cory/b9a6915d7c6b53901359a4fc779efac3 to your computer and use it in GitHub Desktop.
Save alex-cory/b9a6915d7c6b53901359a4fc779efac3 to your computer and use it in GitHub Desktop.
/**
* Only take the specified fields out of the object
*/
const pick = (o, ...fields) =>
fields.reduce((acc, x) => {
if ((o || {}).hasOwnProperty(x)) {
acc[x] = o[x];
}
return acc;
}, {});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment