[Solved] How to use variable instead of function name in JavaScript
Use .call() function callme(a,b){ return a.call(null, b); }; var func = function(c) { return c; }; alert(callme(func, “test”)); Any function you pass to callme will execute there. The first argument is the context, so you could pass this if you need to. Pass null otherwise. In your case, alert/confirm can be passed. If you don’t … Read more