Skip to content

Instantly share code, notes, and snippets.

@psiborg
Created January 6, 2012 08:28
Show Gist options
  • Select an option

  • Save psiborg/1569691 to your computer and use it in GitHub Desktop.

Select an option

Save psiborg/1569691 to your computer and use it in GitHub Desktop.
JS While Loops
// fast
var i = myArr.length;
while (i--) {
console.log(i + ': ' + myArr[i]);
}
// while loop
var i = 0;
while (i < myArr.length) {
console.log(i + ': ' + myArr[i]);
i++;
}
// do while loop
var i = 0;
do {
console.log(i + ': ' + myArr[i]);
i++;
}
while (i < myArr.length);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment