The function and difference of call() and apply().

effect.

Both are used to modify the this of the function to point to the problem.

the difference.

The way they are passed when passing parameters is different.

call()A method can pass parameters to the function as its own multiple parameters.

However, apply()the method needs to encapsulate the actual parameters into an array and pass them uniformly.

Even if there is only one actual parameter, it must be placed in an array.

Guess you like

Origin blog.csdn.net/weixin_46953330/article/details/116013279