All things being equal, it thisrefers when it is used directly inside a function, an object whose function is the method (member), when this function is called in the usual way of obj.method(). Straight means straight; use inside the function nested in this method, regardless of whether it is called anonymously or immediately or not .
In your case
return (function() {
return this.num;
})();
- , this, this - ( ).
, , this, , . , this, .
, :
getNum: function() {
return (() => this.num)();
}
, this.
, :
getNum: function() {
var self = this;
return function() {
return self.num;
}();
}
, , , , . - , :, .
:
getNum: function() {
return function() {
return this.num;
}.call(this);
}
this this getNum, call.
. "his" ?.
""
, , "" " ". , , - , , , . :
, " ".
user663031