I want to pass a link to an arbitrary function by name to another javascript function. If it's just a global function, no problem:
function runFunction(funcName) { window[funcName](); }
But suppose a function can be a member of an arbitrary object, for example:
object.property.somefunction = function() {
runFunction("object.property.somefunction") does not work. I know I can do this:
window["object"]["property"]["somefunction"]()
So, although I could write code to parse the string and understand this hierarchy, it seems to work :) So I thought if there was a better way around this, besides using eval()
source share