+ 12
While and postfix/prefix
var a = 20; var b = 0; a = --a; while(a>a--){ b++; } document.write(b); //outputs 0. I don't understand lines 3-5. Can anyone help? Thank you
2 Respuestas
+ 7
Line 3 decrements a. Line 4 is "while a is greater than a"; then it decrements a (post, not pre) So it will find that a !> a, so b won't be incremented. Therefore b stays at 0 and then is printed.
+ 11
very helpful thank you