I might be a little fat here, but please answer me that. Consider the following code:
a=1; while(a<=6) { console.log(a); a++; }
If I run this, I get the values in the console from 1 to 6, and then another 6.
Now look at this:
a=1; while(a<=6) { console.log(a); ++a; }
Running this will now give me values from 1 to 7.
Why is this happening? My understanding was that an expression block would only be executed if the expression evaluates to true. How is this possible in the second of my examples? And why do 6 appear twice in the first? Very confusing for me.
If you just explain (I'm still studying), that would be great.
Mat richardson
source share