Created
December 28, 2017 04:20
-
-
Save ottonascarella/eb3bb0d827c7d72dbac3345e3f91dd8c to your computer and use it in GitHub Desktop.
gets nested values from within object/array
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 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