Using function.call to Call a Function

In JavaScript, there is a way to call a function by using the .call() method. The syntax of the .call() is as follows:

functionName.call(thisArg, arg1, arg2, ….) // arg1 and arg2 are optional


functionName: Refers to the function being called and. thisArg specifies the object that this references inside the invoked function.

Function.prototype.call()

The call() method calls the function with a given this value and arguments provided individually.


Source: Mozilla, https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call
Creative Commons License This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.