This content originally appeared on DEV Community and was authored by Mayank Yadav
?call()
✔The call() method calls a function with a given this value and arguments provided individually.
✔call() method allows object to use method/function of another object.
✔call() accepts arguments.
?apply()
✔It is similar to call() method but call() method takes argument separately whereas in apply() method arguments are passed as an array.
?bind()
✔It creates a new function and when invoked has the this keyword set to the provided value.
✔In case of call() & apply() the function is immediately called but in case of _bind() it does not call in-fact it just return another function which you can call it later.
That's why in above example I've stored the value in a variable fun and then invoked it.
This content originally appeared on DEV Community and was authored by Mayank Yadav
Mayank Yadav | Sciencx (2021-07-31T15:13:42+00:00) #11) Explain call(), apply() & bind() ❓. Retrieved from https://www.scien.cx/2021/07/31/11-explain-call-apply-bind-%e2%9d%93/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.