Skip to content

Instantly share code, notes, and snippets.

@bjdixon bjdixon/pick.js
Last active May 31, 2017

Embed
What would you like to do?
create a new object extracting only desired properties from a source object. eg pick(['name', 'age'], {name: 'hi', age: 42, alive: true}) == {name: 'hi', age: 42}
const pick = (props, obj) => props.reduce((acc, curr) => ({ ...acc, ...{[curr]: obj[curr]} }), {});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.