Just saw a question about this,
1 var name= "the window"; 2 var object={3 name: "Silence",4 packname:function () { 5 return this.name; 6 }7 }8 Console.log (Object.packname ());
In general, in JavaScript, this points to the current object when the function executes . This refers to object. Output is silence
Change it.
1 var name= "the window"; 2 var object={3 name: "Silence",4 packname:function () { 5 return this.name; 6 }7 }8 var show=object.packname; 9 Console.log (Show ());
When there is no explicit execution of the current object, this points to the Global object window.
Here Show=object.packname;show (); Show does not explicitly indicate the execution object, so it is equivalent to Window.show (); The result is the window
Change it again.
1 var name= "the window";2 var silence={3 name: "Silence",4 packname:function () {5 return this.name;6 }7 }8 var seraph={9 Name: "Seraph",Ten packname:function () { One var fun=silence.packname; A return Fun (); - } - } theConsole.log (Seraph.packname ());
Like 2, fun (); get the Window,fun () to see the function inside the function pointing to the window. That's what I understand.
The this in the function inside the function is pointing to the window