Jump to content
Larry Ullman's Book Forums

Ch6, P198, At The Bottom Of The Page 'Mylist[Length]'


Recommended Posts

Ch6, P198, at the bottom of the page:

 

for (var i = 0; i < myList.length; i++) {
// Do something with myList.
}
The first time the loop is encountered, the i variable is set to 0: the first possible
indexed position. The condition then checks if i is less than the length property
of the array. While that condition is TRUE, the loop’s body can do something with
myList: myList[0], myList[1], and so forth. Then i is incremented. Once i
equals the length of the array, the loop is terminated, as there is no element indexed
at myList[length].

 

"as there is no element indexed at myList[length]."

I think a more accurate description would be "as there is no element indexed at myList[myList.length]."

 

 

Link to comment
Share on other sites

 Share

×
×
  • Create New...