Reputation: 303
I was wondering if self
cause a circular reference by being captured by add
. And will this be a problem for a garbage collector of an old browser.
var fun = function() {
var self = this;
this.value = 0;
this.add = function(number) {
self.value += number;
};
};
fun.prototype.inc = function() {
this.value++;
};
fun.prototype.dec = function() {
this.value--;
};
Upvotes: 0
Views: 32
Reputation: 664920
I was wondering if
self
cause a circular reference by being captured byadd
.
Yes.
And will this be a problem for a garbage collector of an old browser.
No. Not even an ancient one.
Upvotes: 1