The value returned by the original fn after executing with the provided thisArg.
const module1 = {
x: 21,
getX() {
return this.x;
},
};
// The 'this' parameter of 'getX' is bound to 'module'.
console.log(module1.getX()); // 21
// Create a new function 'boundGetX' with the 'this' parameter bound to 'module'.
let module2 = {
x: 42
};
module2.getX = fnBind(module1.getX, module2);
module2.getX(); // 42
// It can also be used to proxy to the original function from the new one
module2.getX = fnBind(module1.getX, module1);
module2.getX(); // 21
Creates a new function that when called will set the value of thisArg as the this keyword
value whrn calling the provided fn instance, and all of the arguments passed to the new
function will be passed along to the original provided instance.
The value returned by the original fn after executing with the provided thisArg.
const module1 = {
x: 21,
getX() {
return this.x;
},
};
// The 'this' parameter of 'getX' is bound to 'module'.
console.log(module1.getX()); // 21
// Create a new function 'boundGetX' with the 'this' parameter bound to 'module'.
let module2 = {
x: 42
};
module2.getX = fnBind(module1.getX, module2);
module2.getX(); // 42
// It can also be used to proxy to the original function from the new one
module2.getX = fnBind(module1.getX, module1);
module2.getX(); // 21
Fallback overload for less-specific Function-typed call sites where the concrete parameter
list is not available, such as dynamic proxy wiring.
The original function type with the bound this value and any provided arguments.
Creates a new function that when called will set the value of
thisArgas thethiskeyword value whrn calling the providedfninstance, and all of the arguments passed to the new function will be passed along to the original provided instance.