1. Call () and apply () Effect:Because JS does not have the concept of private class, we often use these two methods to implement your component when we do the component development, understand this also can help to understand the value of JS "This" (is part of execution context) 2.call () and apply () Source: Call () and apply () is the member method of function (), and other methods are obtained by inheriting the function () through the "--proto--" (implicit prototype).
3.call () and apply () difference: essentially something is the same, the only difference is that the arguments are not the same 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 params in the function class: This is a parameter list 4. Usage Understanding: 4.1 Apply automatically converts a parameter array to a list of parameters that are passed to a method, and your own existing data is an array of parameters, It can be handled conveniently by this time. Eg: Gets the maximum and minimum values in the array: 4.2 Change method The this scope of the class part
JS call () and apply () understand