What is the difference between Call, Apply and Bind in Javascript
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The difference between Call, Apply and Bind can be explained with below examples,
Call: The call() method invokes a function with a given
this
value and arguments provided one by oneApply: Invokes the function with a given
this
value and allows you to pass in arguments as an arraybind: returns a new function, allowing you to pass any number of arguments
Call and apply are pretty interchangeable. Both execute the current function immediately. You need to decide whether it’s easier to send in an array or a comma separated list of arguments. You can remember by treating Call is for comma (separated list) and Apply is for Array.
Whereas Bind creates a new function that will have
this
set to the first parameter passed to bind().