when I looked at the elevation and didn"t know how many times, I thought I had understood something before, but suddenly I was confused
.var name="thi window";
var obj = {
name:"the obj",
getName:function(){
console.log(this);
console.log(this.name);
}
}
obj.getName();
(obj.getName)();
(obj.getName=obj.getName)();
the third output is to print the the window
test, for example, the var ty;
(ty = obj.getName) () / / the window
elevation interpretation is copied and executed first, changing the direction of the this, and the
test is indeed the case. What if the direct call to execute this is obj"s
as long as the assignment is scattered during execution?
if you write separately, you can understand
such as var ty = obj.getName;
ty (); / / the window
, but the parenthesis assignment and execution is a bit difficult to understand. I can only force myself to remember that if the assignment is performing this, change
do you have a better understanding and opinion?