Reputation: 96810
this.f = function() {};
window.d = function() {};
d();
f();
Any difference?
Upvotes: 1
Views: 57
Reputation: 154828
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 set window.a
to 123
var test = new x()
would set test.a
to 123
.Upvotes: 1