I would like to call a function within a function from a string variable with arguments.
Let me demonstrate what I would like with adding some code
var myFunction = function() {
var innerFunction = function(data) {
alert(data);
}
return {
run: function(data) {
innerFunction(data);
}
}
};
var myString = "myFunction.run()";
If I don't want to pass variable than it is quite easy;
var callFunction = new Function(myString);
callFunction();
If I can pass a variable without using function within a function;
function myFunction(data) {
alert(data);
}
var myString = "myFunction";
window[myString]("Hello World!");
However this is not what I want. Could anyone enlighten me about calling a function within a function from a string
variable with passing arguments to it?