This
In a generic strongly typed language, this is the object itself, which can be used in JavaScript
The value of this is part of the execution context environment
In fact this is not very difficult to immediately, just remember two points on it
That's who caller (the caller is who this is pointing to), and if there is an assignment statement, change the type
Let's see a couple of examples.
function Fd () { this. name= "Test"; Console.log (this);}; var f1=New Fd (); // Fd {name: "Test"} Fd (); // window
The first time here is through new, so the caller is F1, and the second is executed directly, and FD is just an expression, which is equivalent to a global function, so he is called by the window
var obj={ x:ten, fn:function () { Console.log (this ); Console.log (this. x); }};o Bj.fn (); // obj,10 var d=obj.fn;d (); // window ""obj.fn.call (); // equivalent to the above code
What about the code above?
In fact, because Obj.fn is assigned to D, and then we call D (), the steps are:
> Our current global context
> Executes d (), enters the FN context, and all callers are window
So here's a proof of the argument that there are assignment statements that change the type.
And of course, there 's a special case.
Because F () is a normal function, all, this points to the window
JavaScript-Learn This