JSFiddle - React, Tailwind, and code Playground
TypeScript
class Debugger {
_log() {
return Function.prototype.bind.call(console.log, console);
}
log = this._log();
specialLog(msg: string) {
return this.log.bind(console, 'special ' + msg);
}
}
const debug = new Debugger();
debug.log('hi'); // works perfect: correct file/line number
debug.specialLog('hi')(); // line number -> where this.log() is called.