Skip to content

Instantly share code, notes, and snippets.

@fredyang
Created March 11, 2015 19:41
Show Gist options
  • Save fredyang/834d70b8f8769ef89b29 to your computer and use it in GitHub Desktop.
Save fredyang/834d70b8f8769ef89b29 to your computer and use it in GitHub Desktop.
function evalObjectPath(hostObj, pathExpression) {
var parts = pathExpression.split('.');
for (var i = 0; i < parts.length; i++) {
var value = hostObj[parts[i]];
if (value === undefined) {
return hostObj;
} else {
hostObj = value;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment