Loop Through Array Without Wasteful Lookups

Submitted by:J Kamy81

Date added:05 February, 2018

Category:JavaScript

Find the length of the array before using it in the for function

Tags: lookup

Code Snippet:

var arLen=myArray.length;

for ( var i=0, len=arLen; i<len; i++ ){
// do something with myArray[i]
}
 
 

Comments