Write a function named customBind that will be used to extend the Function prototype.
It will receive 2 parameters:
newThisparamsThe function should return a new function - let's call it bindedFn - that doesn't accept any parameters.
When calling it we should actually call the initial function but using newThis as the this context and the items inside params Array as arguments.
Function.prototype.customBind = customBind;
function addToThis(nr1, nr2) {
return this + nr1 + nr2;
}
const bindedFn = addToThis.customBind(5, [10, 15]);
console.log(bindedFn()); // 30
Unlock all functions
The first 10 functions are free. Get lifetime access to all 100 with a one-time payment — no subscription.
Upgrade to Pro