The first day on JS, if that. So, there is, for example, such code:
function Object1(a, b) { this.a = 0; this.b = 0; this.sum = function() { alert(a + b); } }; objs = []; for (var i = 0; i < 10; i++) { objs.push(new Object1(1, 1)); } setInterval(function() { for (var i in objs) { objs[i].b++; objs[i].sum(); } }, 200); The alert always displays 2, that is, in fact, the value of b does not change. How can it be changed in these conditions?
alert(this.a + this.b);for a and b do not indicate anything in the function (method) - Alexey Shimansky