2
为什么this
关键字在下面的代码表达不同的价值观?“这个”关键字在javascript返回不同
var t = {
a: "a",
b: {
c: "c",
d: function() {
return this;
}
},
f: function() {
return this;
},
g: this
}
var k = t.f(),
l = t.g;
alert(k); // returns [object object] i.e 't'
alert(l); // returns [object DOMWindow] i.e 'window'
http://stackoverflow.com/questions/3127429/javascript-this-keyword?rq=1 – DCoder 2013-02-28 08:08:44