Created
November 25, 2016 15:13
-
-
Save OzieWest/58ea3c4c03af3ddd6623dac464731484 to your computer and use it in GitHub Desktop.
Accessing nested JavaScript objects with string key
This file contains hidden or 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
| function resolve (path, obj) { | |
| return path.split('.').reduce((prev, curr) => { | |
| return prev ? prev[curr] : undefined; | |
| }, obj) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment