This is the pollyfill bind implementation. My doubt is regarding the args1. How is it possible to accept args1 in the return function of mybind() ? I'm unable to wrap my head around this concept
let person = {
firstname: "Kirtesh",
lastname: "bansal"
}
let printName = function (country) {
console.log(this.firstname + " " + this.lastname + " from "
+ country);
}
Function.prototype.mybind = function(object,...args){
let func = this;
return function (...args1) {
return func.apply(object, [...args, ...args1]);
}
}
let newPrintName = printName.mybind(person, "India");
newPrintName(); ```