So I have a class
class A {
    test() {
        return 1;
    }
    foo() {
        return this.baz(this.bar)
    }
    bar() {
        return this.baz(this.test);
    }
    baz(f){
        return f(); 
    }
}
And when I call the method foo
var a = new A();
a.foo();
I get
Uncaught TypeError: Cannot read property 'baz' of undefined
    at bar (<anonymous>:9:15)
    at A.baz (<anonymous>:12:10)
    at A.foo (<anonymous>:6:15)
    at <anonymous>:1:3
How appears that this becomes undefined after method f() is being called, and how can I fix this?
 
     
    