I was studying the behavior of this inside object methods and I have got stuck at one output.
Here is the code.
'use strict';
let obj, method;
obj = {
go() { alert(this); }
};
obj.go(); // (1) [object Object]
(obj.go)(); // (2) [object Object] QUESTION 2
(method = obj.go)(); // (3) undefined
(obj.go || obj.stop)(); // (4) undefined ------> Doubt <-------------------
So if the fourth one is logically equivalent to the second one, why does the logical OR cause the context to be lost?
Part-2
Please correct me if I am wrong.
The evaluation of this ocurrs the way it is called/invoked with function declaration/expression.
Inside arrow function,
thisalways refers to its enclosing parent . [lexical scope]