When using this, 1. When executing a function, determine whether the function is an object method or a separate function? Separate function this = window; object method, this = object. Copy the code function UseThis () {console. log (this = window); this. instancePro = 1;} UseThis. objPro = 2; UseThis. objMethod = function () {console. log (this. objPro);} UseThis (); // true no matter how deep the nesting is, this = windowconsole in the function when executing the function. log (instancePro); // 1 var useThis = new UseThis (); // false the current value is A constructor. this In the constructor is the console of the new instance. log (useThis. instancePro); // 1 UseThis. objMethod (); // 2 the current function is an object method. this = UseThisvar fn = UseThis. o BjMethod; fn (); // undefined copy the code to open the test page and start the debugger. 2. After the function is returned by the bind method, this points to the first parameter of bind. 3. Execute the function through call (apply). this points to the first parameter of call (apply. Copy the code/* call the function twice */function doubleBind () {console. log (this. doubleVariable);} (function () {console. log (this. doubleCalendar); // 2 doubleBind. call ({doubleVariable: 1}); // 1 }). call ({doubleVariable: 2}); copy code 4. a function that calls bind first, and then uses call for execution. this points to the first parameter of bind. /* Bind the function to Bind the return function and call */function funBind () {console. log (this. pro);} var relFun = funBind. bind ({pro: 2}); relFun. call ({pro: 3}); // copy the code var con_inObj = {variable: "sprying", cons_fun: function () {console. log (this. variable) ;}} var new_obj = new con_inObj.cons_fun ();//? <! -- From front-end stew --> var x = 5; var example = {x: 100, a: function () {var x = 200; console. log ('a context: % s, var x = % s', this. x, x) ;}, B: function () {var x = 300; return function () {var x = 400; console. log ('B context: % s, var x = % s', this. x, x) ;}}, c: function () {var other = {x: 500}; var execB = this. B (). bind (other); execB (); return execB ;}} console. log ('example. x: '+ example. x); example. a (); example. B (); example. a. call ({x: 9999}); var execB = example. c (); execB. call ({x: 9999}); copy the code