What is the difference between $.proxy() and bind()?

前端 未结 5 1514
暖寄归人
暖寄归人 2021-02-03 22:43

In 2009, ECMAScript 5 added a built-in bind() function which takes an object as a parameter and returns an identical function in which this will always

5条回答
  •  佛祖请我去吃肉
    2021-02-03 23:07

    proxy came first and you should likely favor bind as it is a standard. The way they are called varies slightly (due to being attached to Function.prototype vs just being a function) but their behavior is the same.

    There is a pretty good post here: jQuery.proxy() usage, that ends with that advice.

提交回复
热议问题