Skip to content

Instantly share code, notes, and snippets.

@hpohlmeyer
Created January 2, 2015 17:17
Show Gist options
  • Save hpohlmeyer/8c22440da7ff4b52384b to your computer and use it in GitHub Desktop.
Save hpohlmeyer/8c22440da7ff4b52384b to your computer and use it in GitHub Desktop.
loop operator tests
/*
* 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