I think you can do this with the "new Function" operator. I never used it myself, since I'm not crazy crazy, but I believe that you can pass it a string that will be eval uate and used as the body of the function. You can also get the code for each function by calling myFunction.toString() . So it will be something like this:
var functionsToMessUp = ['myFunc1', 'myFunc2']; for (var i = 0; i < functionsToMessUp.length; ++i) { var theFunc = window[functionsToMessUp[i]];
Now this will almost certainly not work - the parameters and other things will be taken into account there, and I donβt even think how the new Function constructor works, but if you really want to go this way (which I really do not recommend), then this can be good starting point for you.
source share