Skip to content

Instantly share code, notes, and snippets.



Last active May 31, 2017
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