Skip to content

Instantly share code, notes, and snippets.

@nola
Created November 26, 2013 02:10
Show Gist options
  • Select an option

  • Save nola/7652461 to your computer and use it in GitHub Desktop.

Select an option

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.
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
}
@nola
Copy link
Copy Markdown
Author

nola commented Nov 26, 2013

Count down to zero

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment