Last active
May 31, 2017 07:33
-
-
Save bjdixon/8e5eb9de04074a11f08c9e1af1e14aec to your computer and use it in GitHub Desktop.
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}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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