Last active
August 29, 2015 14:07
-
-
Save Daniel-Wiedemann/7ac1dc268e2337d0c72d to your computer and use it in GitHub Desktop.
Decrement for Loop (or. negative for loop)
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
| 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