Jump to content
Larry Ullman's Book Forums
Sign in to follow this  
Christopher

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]."

 

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...