Function.prototype.call() own in-depth understanding, summary

definition

A Function.call() method
is to use a specified this value , and a single given parameter list to call this function.

principle

The call function is used to change the this pointer of the caller.

Let me say a little more:
The principle of f.call(obj) is to mount the function f to obj. When f.call(obj) is executed, this in f points to obj .

Why create call

Why does call appear: call and apply appear to dynamically change this . When an object does not have a certain method, but others do, we can use call or apply to operate with methods of other objects.

Guess you like

Origin blog.csdn.net/qq_30738155/article/details/127197607