Objective
This
This is detailed in JavaScript
This detailed
How many cases does this point to? How is human control?
"Who calls This,this point to who!!" 】
"This point, do not care where this is written!! Only care about the function that contains this, who calls!! 】
① through () direct call, this point to Window func ();
The ② object. The function call, this points to the current object. Obj.func () Div.onclick = function () {}
③ array subscript called, this points to the current array [func,1,2,3]---àarr[0] ();
④ the callback function for all built-in functions, this points to window SetTimeOut (function () {},1000);
Human control:
The ⑤ is called by the New keyword, which points to the empty object that is newly created. Var obj = new func () {} this-obj
⑥ is called by call, apply, bind and this points to the object we specify.
Func.call (obj, parameter one, parameter 2, Parameter 3 ....) )
Func.allply (obj,[parameter one, parameter 2, Parameter 3 ....) ])
Func.bind (obj) (parameter I, parameter 2, parameter 3) var f = func.bind (obj). f (...);
This is detailed in JavaScript