With reference to the following script...
var a=("123");
document.write(a + " is the value of a when first assigned" + "</br>");
var b=(a++);
document.write(b + " is the value of b when first assigned" + "</br>");
document.write(a + " is the value of a AFTER b first assigned" + "</br>");
...and its output...
123 is the value of a when first assigned
123 is the value of b when first assigned
124 is the vaule of a AFTER b is first assigned
...can anyone tell me what the statement...
var b=(a++);
...is actually doing?
I've used var b=(a++) to "convert" the numeric string a to an integer b so that I can perform various operations on string a using its integer or b form: e.g. (b+1), (b-1) etc.
However, it also seems the assignation of a to b via var b=(a++) converts a into an "unassigned" integer, or "über a" with the value (a+1)....
The thing I can't figure out is why the "integer value" of a doesn't remain exclusively associated with the variable - in this case b - to which it was very specifically assigned? Why does a "new" value of a spill or leak out of the assignation of a to b?
Essentially, how can a become an integer if I haven't made it one? How does a become "changed" by an operation I've specifically and only assigned to b?
Thanks for any clarification!