I am going to store some function names as strings and then use them later to make the call. I'm familiar with the pattern:
window[myStringName]();
However this does not work if the function I want to call is not directly exposed globally. I am trying to keep things namespaced and only have 1 global variable exposed for the entire script. So the question is, how do I call either of these inner functions without using eval?
var myFunc = (function(myFunc){
myFunc.myInnerFunc = function(){
alert('hi');
};
myFunc.myObj = {
innerObjFunc: function(){
alert('howdy');
}
};
return myFunc;
}(myFunc || {}));
Or are there even any drawbacks to using eval? I was under the impression that eval is evil and should never be used or else Douglas Crockford will leave a lump of coal in my stocking.
Here is where I was going to split the string and then somehow be clever in building the call, but I am not sure how...