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

前端 未结 5 1501
暖寄归人
暖寄归人 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:13

    Here is a test you could try to for performance comparison.

    http://jsperf.com/bind-vs-jquery-proxy/5

    At this time, October 2014. The performance varies like crazy between browsers. IE 11 native bind is fastest.

    However, for all three browsers I tested with, native bind out preform jquery proxy. And since bind() is standard, I would suggest sticking to it if possible.

提交回复
热议问题