Look at the code below to see how we defined a variable and specified a function within it to get the intended result.
Call Method
Let's declare another variable, and if you think declaring that function again here will be acceptable, think again. This is not a good practise. So this is where call method comes in picture.
Apply Method
The apply method is extremely similar to the call method, with the main difference being how we pass arguments, with the first argument being a reference to this and the second argument being a list of the arguments that we pass in the function. Instead of sending these arguments individually using a coma in call method, we pass them in an array list to the apply method.
Bind Method
The bind method is quite similar to the call method, with the exception that the bind method links this method (function name) with the object and then returns a copy of the method (that function). There is a catch over there that does not directly call the function but instead returns a duplicate of that function that we can call later.
Thank you for reading.
Top comments (0)