I am having trouble to get my head around this one. I am aware of scope chaining, callbacks in javascript, the value of this in the callbacks and hence the arrow functions.
In javascript, closures have access to variables of the enclosing function via the scope chain. So why the closure does not access the 'this' bound via Function.prototype.bind to the parent function of closure ? Is the variable 'this' not a part of the scope chain?
Ran the following code inside the chrome console :
a = 4;
b = 6;
function outer(){
function inner(){
console.log(`this.a is ${this.a} and this.b is ${this.b}`);
}
inner();
}
outer.bind({a:1,b:3})()
and the console threw back :
this.a is 4 and this.b is 6