comments | Javascript source | Execution result in your current browser |
---|---|---|
global execution context | document.write("global this="+this); |
|
inside literal object | var obj1={ name:"object 1", f: function() { document.write("call inside object: "+this.name); } }; obj1.f(); |
|
resign the same function to another object | var obj2={name:"object 2", f:obj1.f}; obj2.f(); |
|
this.name="global1"; var globalFunc=obj2.f; globalFunc(); |