Using function.bind to Create New Functions

The bind() method does not invoke a function but instead takes an existing function and creates a new function with a specified value for "this" inside the new function.

The syntax of the bind() method is:

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

Function.prototype.bind()

The bind() method creates a new function that, when called, has its this keyword set to the provided value, with a given sequence of arguments preceding any provided when the new function is called.


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