In JavaScript, apply () has the same meaning as call (), which is the direction of this change in the calling function.
Where the first parameter of apply () and call () represents the object to point to, the default is window if the calling function has no arguments to write.
The argument after the first parameter represents the parameter that invokes the function, where the argument after the first argument is an array, and the first parameter of call () is followed by 0 or more parameters.
Cases:
1window.x = 100;2 3 4 varobj = {};5obj.x = 1;6Obj.test =function(a) {7Alert This. x + 20 +a);8 }9 Ten One varABC = {}; Aabc.x = 2; -Abc.test =function() { -Alert This. x + 30 +a); the } - - -Obj.test (10);//The result is 31,this pointing to obj +Obj.test.call (window, 10);//result for 130,this point to Window -Obj.test.call (ABC, 10);//results for 32,this point ABC + A atobj.test.apply (window, [10]);//result for 130,this point to Window -Obj.test.apply (ABC, [10])//results for 32,this point ABC