What's the purpose of using Function.call.apply in JavaScript?

后端 未结 2 1360
予麋鹿
予麋鹿 2020-12-02 21:38

I was browsing through the JavaScript Garden when I stumbled upon the Function.call.apply hack which is used to create \"fast, unbound wrappers\". It says:

2条回答
  •  一整个雨季
    2020-12-02 21:59

    It means you can use the methods from an object on another one.

    A good example is the arguments variable all functions have, it's like an array but not an array so you can call array's methods on it thus:

    Array.prototype.join.call(arguments, ",");
    

提交回复
热议问题