5 - Javascript:Arrays - Document arrays
The document object stores most of the information about the contents of a document in a collection of arrays. For instance, the information about the images in the document are stored in an array called images[ ]. The images are assigned to the array in the order they appear in the code. There is another array for the forms[ ] in the document, which itself contains an array of the input elements[ ] in the form. We've already used the forms and elements arrays in an earlier lesson. A third array stores the links[ ] in the document. There are more arrays available, but this is good to start with.
Image Arrays
The images[] array stores information about the images in the document. They
are added to the array in the order in which they appear in the code. Thus,
if you wanted to find out what the URL of the first image in the document was,
you could check the value for document.images[0].src. The src attribute is where
you assign the URL of the image in the code, so it should make sense that the
name of the property that stores it is also src.
But what happens if you don't want to have to keep track of the order in which the images occur in the document. Well, JavaScript allows you to refer to the images in the document by name. When you use the name attribute in an image tag to assign a name to the image, you can then use the name you assigned it as a property of the document object.
So take a look at this,