I am running a self executing function in javascript to not interfere with any global variables on a page. I have a string with the name of a function I want to call. The function is declared inside my self-executing function. Is there a way to call that function by using the string?
(function(document, window){
var functionName = "myFunction";
window[functionName](); //This does not work...
function myFunction(){
//Do some stuff
}
}(document, window)
I found this: How to execute a JavaScript function when I have its name as a string
but my function is self executing without a name, so I have no way to reference it with the window variable.