When I call one function, "this" contains all the the "stuff", but when I call a function that calls another functions, "this" returns undefined inside the second function.
Code:
class test {
test() {
console.log(this) // => returns class functions ect..
this.run(this.test2);
}
run(func){
func()
}
test2() {
console.log(this) // => returns undefined
this.function3(); // => ERROR
}
function3() {
console.log("hey")
}
}
var t = new test();
t.test();
Why does the code behave this way? and how do I resolve this issue