1. Overview
Function.apply (Obj,args) method can receive two parameters
Obj: This object will replace the This object in the function class
Args: This is an array, which is passed as a parameter to function (args-->arguments)
Function.call (obj,[param1[,param2[,... [, Paramn]]])
Obj: This object will replace the This object in the function class
Params: This is a list of parameters
(has not understood, changed the context scope, now understand, this point)
2, the understanding of apply and call,
is to bind the attribute method inside the function to obj, Because the context is changed, so the t inside the function His will point to obj (this property will produce some advanced usage)
3. Difference between apply and call
is to pass the parameters in a different way, you think,function inside will accept parameters , when obj inherits the function, then the function has parameters, then
and pass it over from there? So only arguments, think so, I sometimes want a whole piece (array) pass through (apply), and sometimes want to preach (call)
4,Some special ways to use apply
Because apply can pass an array (), then it can be Math.max.apply (Null,[paramn]);
Apply and call