Javascript - get path to object object
4 answers
Another way:
function resolve(root, path){
try {
return (new Function(
'root', 'return root.' + path + ';'
))(root);
} catch (e) {}
}
resolve(obj, 'foo.bar'); // "I want this"
More on this: fooobar.com/questions/4051 / ...
-1
source to share