js call and apply function

obj.call(thisObj, arg1, arg2, ...);
obj.apply(thisObj, [arg1, arg2, ...]);

Both have the same function, both bind obj (that is, this) to thisObj. At this time, thisObj has the properties and methods of obj. Or thisObj "inherits" the properties and methods of obj.

The only difference is that apply accepts array parameters, and call accepts continuous parameters.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324689355&siteId=291194637