A function, such as below, may have a local function defining this.inc
. Changing the value Is there any explanation as to what inc
to any other, such as say i
, changes the result - so clearly, this .inc
is not a user defined variable, but something else internal to this
.inc
is, and why it functions like so?
function incr () {
var i = 0;
this.inc = function() {
i++;
}
}
This change in result can be observed in an answer to my previous question, found here, such as in this construction (Thanks to Paul S for expanding it from a Ternary Operator):
if (total !== 0) {this.inc = (this.inc || 0) + 1;} else {this.inc = -1 +1;}
So, to reiterate, changing So, what exactly is this.inc
to this.i
(or any other variable presumably) does not work, but this.inc
does work.this.inc
?
Due to my tiredness and incorrectly testing this.inc
before posting this question, I misunderstood the usage of the variable inc
as being internal to this
, rather than miscellaneously defined by the programmer, since changing it was not initially working for me. Due to this, this question is requested for deletion.