Skip to content

Instantly share code, notes, and snippets.

@jfromaniello
Created June 17, 2014 18:35
Show Gist options
  • Save jfromaniello/0afa1325d153030ad960 to your computer and use it in GitHub Desktop.
Save jfromaniello/0afa1325d153030ad960 to your computer and use it in GitHub Desktop.
var foo = {
a: {
b: {
c: 456
}
}
};
function getProp(obj, path) {
return path.split('.').reduce(function (prev, curr) {
return prev[curr];
}, obj);
}
console.log(getProp(foo, 'a.b.c'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment