DEV Community

Discussion on: Difference between call,apply and bind

Collapse
 
hebashakeel profile image
hebaShakeel

We use call, bind and apply methods to set the 'this' keyword independent of how the function is called. This is especially useful for the callbacks. Also, functions are a special kind of objects in JavaScript. So they have access to some methods and properties. Call, bind, and apply are some of the methods that every function inherits.

Collapse
 
ciochetta profile image
Luis Felipe Ciochetta

ah, got it

really hadn't thought about callbacks, but that makes some sense

Thread Thread
 
alifattah profile image
Ali Fattah • Edited

Sometimes the bind() method has to be used to prevent losing this, especially in callback. but actually, in ES6 we use the arrow function instead of bind hack to avoid such unwanted mistakes!✌