Call Function with Custom Context

Medium

Solution

declare global {
  interface Function {
    callPolyfill(context: Record<any, any>, ...args: any[]): any;
  }
}
 
Function.prototype.callPolyfill = function (context, ...args): any {
  return this.bind(context)(...args);
};
 
export {};