Call Function with Custom Context

Medium

Solution

/* eslint-disable @typescript-eslint/no-explicit-any */
 
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 {};