Created
February 7, 2020 03:59
-
-
Save geocine/4e53bd19abfcad96050ae34b586eeacd to your computer and use it in GitHub Desktop.
Filter Props
This file contains hidden or 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
function filterProps(keys, obj) { | |
return Object.keys(obj).reduce((curr, key) => { | |
if (keys.includes(key)) { | |
curr = { | |
...curr, | |
[key]: obj[key] | |
}; | |
} | |
return curr; | |
}, {}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment