Is there a way to call a function like item_edit.say hello by passing it as a string on the window object (similar to the last line in the snippet below)?
var arc={ view: { item_edit: {} } };
arc.view.item_edit={
say_hello: function(){
alert('hello there');
}
}
var f_name='say_hello';
var g_name='item_edit.say_hello';
var str=window.arc.view.item_edit[f_name](); // <- this works
var str2=window.arc.view[g_name](); // <- this is what I'm interested in; currently doesn't work
Do you have any suggestions on how to make this work?
Thank you in advance.
Update #1: I should mention that I probably don't want to use eval, although upon further consideration, it may actually be the most sensible approach (and is, in fact, what eval was designed for).