JSFiddle - React, Tailwind, and code Playground
JavaScript
function customBind(func, context) {
const args = Array.from(arguments).slice(2,);
return function(...other) {
return func.call(context, ...args, ...other);
};
}
const obj = {
hi: 'hey'
};
function sayHi() {
console.log(this.hi);
}
customBind(sayHi, obj)();