Skip to content

Instantly share code, notes, and snippets.

@rvgpl
Created August 2, 2018 16:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rvgpl/aef402d8c1860ee89604632ac0b54842 to your computer and use it in GitHub Desktop.
Save rvgpl/aef402d8c1860ee89604632ac0b54842 to your computer and use it in GitHub Desktop.
deeply nested values
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