I have a problem with modify variable transfered as function parameter. For example:
function fun() {
this.a = 1;
this.b = 2;
this.show = function() {
this.increment(this.a);
this.increment(this.b);
console.log(this.a); // expected 2
console.log(this.b); // expected 3
}
this.increment = function(elem) {
elem += 1;
}
}
var funObj = new fun();
funObj.show();
How can I change this.a and this.b variables in this case?