Skip to content

Instantly share code, notes, and snippets.

@iksi
Created August 6, 2019 07:57
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 iksi/e9e39ac29dfbf3fe0b59ebf541513b95 to your computer and use it in GitHub Desktop.
Save iksi/e9e39ac29dfbf3fe0b59ebf541513b95 to your computer and use it in GitHub Desktop.
vanilla js functions
// Get deep value from object by passing path to it as an array
const path = (pathArray, nestedObject) => pathArray.reduce((object, key) => (
object && object[key] !== 'undefined' ? object[key] : undefined
), nestedObject);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment