Created
November 26, 2013 02:10
-
-
Save nola/7652461 to your computer and use it in GitHub Desktop.
Decimal base exponents
You can use 1 and 0 to represent true and false. I’ve seen this used in JavaScript game development in shorthand while loops. Note that if you use the negative start your array may be in reverse. You can also use while(i++<10) and you don't have to add the i++ later on inside the while.
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
| var i=0; | |
| while (i<9) | |
| { | |
| //do stuff | |
| i++; //say | |
| } | |
| //shorthand | |
| var i=9; | |
| while(i--) | |
| { | |
| //goes until i=0 | |
| } | |
| or | |
| var i=-9; | |
| while(i++) | |
| { | |
| //goes until i=0 | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Count down to zero