Created
January 2, 2015 17:17
-
-
Save hpohlmeyer/8c22440da7ff4b52384b to your computer and use it in GitHub Desktop.
loop operator tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* i-- | |
* Range: 9…0 | |
* After Loop: -1 | |
* Decrementation: After while condition check; before loop body. | |
*/ | |
var i = 10; | |
while (i--) {…} | |
/* | |
* --i | |
* Range: 9…1 | |
* After Loop: 0 | |
* Decrementation: Before the while condition check. | |
*/ | |
var i = 10; | |
while (--i) {…} | |
/* i-=1 | |
* Range: 9…1 | |
* After Loop: 0 | |
* Decrementation: At the place of occurence | |
*/ | |
var i = 10; | |
while (i-=1) {…} | |
/* do --i | |
* Range: 10…1 | |
* After Loop: 0 | |
* Decrementation: After do, before condition check | |
*/ | |
var i = 10; | |
do {…} while (--i); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment