Last active
July 9, 2017 23:12
-
-
Save JoaoCnh/12125f8b0309e97eb1871e6bdf67f48c to your computer and use it in GitHub Desktop.
js optimized for loop
This file contains 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
// normal loop | |
for (var i = 0; i < array.length; i++) { | |
console.log(array[i]); | |
} | |
// optimized loop | |
for (var i = array.length - 1; i >= 0; i--) { | |
console.log(array[i]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment