Created
August 2, 2018 16:00
-
-
Save rvgpl/aef402d8c1860ee89604632ac0b54842 to your computer and use it in GitHub Desktop.
deeply nested values
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 get = (obj, path) => path.reduce((acc, value) => (acc && acc[value] ? acc[value] : null), obj); | |
//get(object, ['level1', 'level2','level3']) | |
const get1 = path => obj => path.reduce((acc, value) => (acc && acc[value] ? acc[value] : null), obj); | |
// get1(['level1', 'level2','level3'])(object) | |
// const getItems = get1(['level1', 'level2','level3']); | |
// getItems(object) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment