Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

21 lines (15 sloc) 0.345 kB
title level source attribution
Cache Length During Loops
intermediate
jQuery Fundamentals

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

var myLength = myArray.length;

for ( var i = 0; i < myLength; i++ ) {

  // do stuff

}
Jump to Line
Something went wrong with that request. Please try again.