As the function to access the class?

Good day, there is code in JS (Babel):
class ExtensionLogger {
 constructor(isClient = false, scopeName = ", target = window) {/* ... */)
 attachLoogger() {
 this.targetWin.console.log = function (...message) {
 this.oldObj.log(message); //Why this in this case, the console object instead of class? How to access class?
 this.dispatchMessage('log', message);
};
....


Study Babel, in this case write the mechanism of logging and debug reset add to the file.
This is why the console object and not my class? How do I get to a class instance?
June 14th 19 at 19:06
2 answers
June 14th 19 at 19:08
Solution
So get, for example:
this.targetWin.console.log = function (...message) {
this.oldObj.log(message)
 this.dispatchMessage('log', message);
}.bind(this);
June 14th 19 at 19:10
class ExtensionLogger {
 constructor(isClient = false, scopeName = ", target = window) {
 this.attachLoogger = this.attachLoogger.bind(this);
}

 attachLoogger() {
 this.targetWin.console.log = function (...message) {
this.oldObj.log(message);
 this.dispatchMessage('log', message);
}
}
}

Find more questions by tags JavaScript