I know that arrow functions inherit this
from enclosing scope. Yet, still can't understand why this
in arrow function defined in object literal points to global object, while in constructor to created object.
Consider following code:
function Obj() {
this.show = () => {
console.log(this);
};
}
const o = new Obj();
const o2 = {
show: () => {
console.log(this);
}
}
o.show(); // o
o2.show() // window || undefinded