I have a function which is called with a callback. I need to call() this callback with the "this" argument, but it doesn't work !
I have try to call a private function, and it works, but it doesn't work with the cb...
function foo(cb) {
this.test = "IT WORKS"
cb.call(this);
}
foo(() => {
console.log(this);
});
The result expected in the console should be {text: "IT WORKS"}
but the actual output is the Window object.
The question is also: Why i can not call() a callback with this