PHP Common Call_user_func method, in JS sometimes used, such as you want to according to a dynamic variable to execute the method.
There have been similar problems have not been solved, and now do not quite remember the specific case. Today, I stumbled across a similar article and learned it. The code is as follows:
<script>function Call_user_func (CB, params) {func = window[cb];func.apply (CB, params);} var funcs = [' test1 ', ' test2 '];for (var i=0;i<funcs.length;i++) {Call_user_func (funcs[i], ["DDD", "CC"]);} function Test1 (A, b) {Console.log (A + B + ' is a good gay ');} function Test2 (A, b) {Console.log (a+b+ "is SB");} </script>
The call () and apply () methods in JS are methods that invoke an object and point the pointer to another object
<script>function test3 () {this.name = "ddd"; this.showname = function () {alert (this.name);}} function test4 () {this.name = "CCC";} var t4 = new test4 (), var t3 = new Test3 (); T3.showName.call (T4);</script>
JS in the Call_user_func package