4 ms·
In practice though, many places that used apply/call tend to bind instead.
by singlow 4y ago
In practice though, many places that used apply/call tend to bind instead.
- 29athrowaway 4y agoapply and call invoke a function with a specified receiver object, and arguments. bind creates a new function that is bound to a specified receiver.
- singlow 4y agoOne of the most common places front-end devs encountered call/apply was when binding functions to event handlers. In those cases an anonymous function was often generated which used apply or call. Bind replaces this dance for many cases. Hence, most cases where devs encountered js call/apply were replaced by bind. There are differences between the two, but they largely didn't matter for most cases.
- 29athrowaway 4y agoUnless you have strict performance requirements, then it does matter.