class b {
constructor(){
this.name = 'bar'
}
b1(){
console.log('here: ', this.name);
function c() {
console.log('inside c: ', this.name)
}
c();
}
}
let a = new b;
a.b1();
//output:
// here: bar
// inside c: undefined
In this case, when calling a.b1(), in the scope of function b1, the this context is bind to a. But when executing function c inside function b1, why the this context is lost? this suppose in the closure of function c ?
I know how to make it work (arrow function). Just wondering why.