Cache Length During Loops

jQuery

Cache Length During Loops

In a for loop, don't access the length property of an array every time; cache it beforehand.

1
2
3
4
5
6
7
                          
var myLength = myArray.length;
for ( var i = 0; i < myLength; i++ ) {
// do stuff
}