1:
1Window.id= ' Windowid ';2 functionM () {3 This. id= ' Mid ';4 This. f1=function() {Console.log ( This. id);}; 5 This. f2=function(){6 var that=this; 7 setTimeout (that.f1,5000);8 };9 } Ten varm=NewM (); OneM.f2 ();//' Windowid '
2:
window.id= ' windowid ' ; function M () { ; function () { Console.log (this .id);}; function () {settimeout ( this.f1,5000 Span style= "color: #000000;" > };} var m=new M (); M.f2 (); // ' Windowid '
3:
Window.id= ' Windowid ';functionM () { This. id= ' Mid '; This. f1=function() {Console.log ( This. id);}; This. f2=function() { setTimeout ( function () {this.f1 ();},5000); };} varm=NewM (); M.f2 (); //error:undefined is not a function
4:
1Window.id= ' Windowid ';2 functionM () {3 This. id= ' Mid ';4 This. f1=function() {Console.log ( This. id);}; 5 This. f2=function(){6 var that=this;7 setTimeout (function () {that.f1 ();},5000);8 };9 } Ten varm=NewM (); OneM.f2 ();//' Mid '
The This in SetTimeout ()