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

前端 未结 5 1503
暖寄归人
暖寄归人 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 22:58

    From Underscore bind vs jQuery.proxy vs Native bind

    In addition to what is already mentioned, there's another difference between $.proxy() and .bind. Methods bound with $.proxy will return the same reference if called multiple times; jQuery caches functions proxied to an Object.

    jsFiddle

提交回复
热议问题