Created
May 10, 2011 19:22
-
-
Save st3v3nhunt/965186 to your computer and use it in GitHub Desktop.
JS for iterator caching
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
// no caching of iteration size | |
for (var i=0; i<myArray.length; i++) {} | |
// caching of iteration size - ugly version | |
var length = myArray.length; | |
for (var i=0; i<length; i++) {} | |
// caching of iteration size - nice version | |
for (var i=0, len=myArray.length, i< len; i++) {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment