Suppose I have a function a:
function a() { this.b = 1; this.set = setInterval(function() {console.log(this.b);}, 200); }
So when
In your case, you can simply:
function a() { var _this = this; this.b = 1; this.set = setInterval(function () { console.log(_this.b); }, 200); }
Normally, we can also have a helper method Function.prototype.bind to fix the this reference.
this