I have a a function that takes a string like "obj.key.subkey.subsubkey"
:
function(obj, key) {
return eval('obj.'+ key);
}
What would be a safe alternative to eval
in this case or is eval
fine? new Function
won't work in this case AFAIK. Maybe split
and loop then?