Skip to content

Instantly share code, notes, and snippets.

@ottonascarella
Created December 28, 2017 04:20
Show Gist options
  • Save ottonascarella/eb3bb0d827c7d72dbac3345e3f91dd8c to your computer and use it in GitHub Desktop.
Save ottonascarella/eb3bb0d827c7d72dbac3345e3f91dd8c to your computer and use it in GitHub Desktop.
gets nested values from within object/array
const getIn = (...path) => target => {
return path.reduce((obj, k) => {
return (obj == null) ? obj : obj[k];
}, target);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment