Re: Javascript Race Wizard |
Wed, 17 June 2009 21:23 |
|
|
sirgwain wrote on Thu, 18 June 2009 04:20 |
for (h = 0; h < 3; ++h)
|
the difference between h++ and ++h the is order of the incrementing of h and evaluation of the expression as a whole:
++h increments h before the evaulation and thus affects the evaluation.(preinc)
h++ increments h after the evaluation and thus does not affect the evaluation.(postinc)
The simplest examples are:
h=1;
x=(++h);
//A
h=1;
y=(h++);
//B at both points (A&B) h has been incremented so h=2 but at A, x=2 and at B, y=1.
The third part of the for loop tuple is a statement to be run after each iteration. As a stand alone statement not included as part of a larger expression, both h++ and ++h have the same effect since the evaluation is never used - such as in a for loop.
[Updated on: Wed, 17 June 2009 21:30] Report message to a moderator
|
|
|