Skip to content

Instantly share code, notes, and snippets.

@Daniel-Wiedemann
Last active August 29, 2015 14:07
Show Gist options
  • Save Daniel-Wiedemann/7ac1dc268e2337d0c72d to your computer and use it in GitHub Desktop.
Save Daniel-Wiedemann/7ac1dc268e2337d0c72d to your computer and use it in GitHub Desktop.
Decrement for Loop (or. negative for loop)
for(var i = array.length; i--;) {
// do something
}
// =====================================
// example
var letters = ['a','b','c','d','e','f'];
for(var i = arr.length; i--;){
console.log(arr[i]);
}
// output:
// f
// e
// d
// c
// b
// a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment