Why does Array.prototype.reduce not have a thisObject parameter?

后端 未结 3 1206
南方客
南方客 2020-12-31 04:49

Javascript Array methods such as forEach have a thisArg parameter, which is used as the context for invoking the callback:

array.fo         


        
3条回答
  •  暖寄归人
    2020-12-31 05:09

    On the Es-discuss mailing list you find in answer http://article.gmane.org/gmane.comp.lang.javascript.ecmascript4.general/4770

    The other methods with callbacks take a 'thisArg' not because it is needed or even useful, but for compatibility, because they already do in existing implementations that provide these functions.

提交回复
热议问题