I've been unable to find the answer to this, say for example you have the array:
var myArray = ["a","b","c","d","e","f","g"]; // pretend I define up to 1000 elements
One simple approach to iterate through the array would be:
for(var i=0; i<myArray.length; i++){
console.log(myArray[i]);
}
What I'm trying to figure out is if the .length property will be evaluated on each iteration, then if I use:
my len = myArray.length;
for(var i=0; i<len i++){
console.log(myArray[i]);
}
Does the 2nd approach will be a performance improvement ? Does the JS
engine will calculate the length
on each iteration?