3 ms·
> Because the bind function implementation shows why it is so slow. Does it? I'm not going to pretend to know why that would be. Your explanation would be welc
by juliangregorian 11y ago
> Because the bind function implementation shows why it is so slow.
Does it? I'm not going to pretend to know why that would be. Your explanation would be welcome.
I don't know if this sebmck fellow has benchmarked the code, but another commenter below found it to be a whopping 25% faster. Micro-optimizations, anyone?
> 99.5% of JS programmers will never read the spec
You don't have to read the spec, it's literally the first thing after the description paragraph on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
As others have mentioned, when I bind a function, I don't expect it to be able to be messed with.
Anyway, I'm done debating, but it should be quite obvious that there's no need to throw bind() away.
- hajile 11y agohttps://web.archive.org/web/20141121220218/http://jsperf.com/function-calls-direct-vs-apply-vs-call-vs-bind/33 https://web.archive.org/web/20141121220218/http://jsperf.com... In FF39 on my machine, .bind() is between 5 and 20x slower. In Chrome 43, it's between 2 and 20x slower compared to call and apply and 200x slower compared to normal function calls (I ran several times and don't fully understand why Chrome optimizes the hell out of normal function calls). I would encourage you to run it for yourself and see.