I was browsing around and I found this:
var i, len;
for(i = 0, len = array.length; i < len; i++) {
//...
}
My first thoughts are:>
A loop consisting of three parts is executed as follows:
for (A; B; C)
A - Executed before the enumeration
B - condition to test
C - expression after each enumeration (so, not if B evaluated to false)
So, yes: The .length
property of an array is checked at each enumeration if it's constructed as for(var i=0; i
Equivalent to for (var i=0; i
var i = 0;
while (i < array.length) {
...
i++;
}