this.f = function() {};
wind开发者_StackOverflow中文版ow.d = function() {};
d();
f();
Any difference?
Not if it's run barely (e.g. not within special functions etc.). Because then this === window
.
In constructor functions etc. this
has another meaning, so then it matters:
function x() {
this.a = 123;
}
Now,
x()
would setwindow.a
to123
var test = new x()
would settest.a
to123
.
精彩评论