Created
March 11, 2015 19:41
-
-
Save fredyang/834d70b8f8769ef89b29 to your computer and use it in GitHub Desktop.
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 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