Skip to content

Instantly share code, notes, and snippets.

@alexwright
Created May 6, 2013 17:43
Show Gist options
  • Save alexwright/5526721 to your computer and use it in GitHub Desktop.
Save alexwright/5526721 to your computer and use it in GitHub Desktop.
Traverse an object based on dot notation.
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