Skip to content

Instantly share code, notes, and snippets.

@nifl
Created April 3, 2014 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nifl/9959412 to your computer and use it in GitHub Desktop.
Save nifl/9959412 to your computer and use it in GitHub Desktop.
JS Loops

Loops

While loops are initialized outside of the loop, eg in a var

var number = 0;
while (number < 10) {
    console.log(number);
    number++; // incrementer inside loop
}

For loops are initialized and incremented as parameter expressions

for (var number = 0; number < 10; number ++) {
    console.log(number);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment