Created
May 6, 2013 17:43
-
-
Save alexwright/5526721 to your computer and use it in GitHub Desktop.
Traverse an object based on dot notation.
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
a = {foo:{bar:{baz:42}}}; | |
"foo.bar.baz".split('.').reduce(function(o, i) { return o[i]; }, a); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment