JSFiddle - React, Tailwind, and code Playground
by colorkid
JavaScript
const obj = {
name: 'John'
}
function bindPolyfil(fn, context) {
return function() {
return fn.apply(context, [...arguments]);
}
}
function foo(a, b, c, d) {
const str = `${this.name} ${a} ${b} ${c} ${d}`;
return str;
}
let bindedFoo = bindPolyfil(foo, obj);
console.log(bindedFoo(54, 6, 34, 545));