JavaScript's Built-In Arrays

When a web browser reads an HTML page, it automatically creates a number of arrays. In the previous chapter we saw that JavaScript creates an array for each set of radio buttons with the same name. If you create a set of radio buttons named age inside a form named the_form, you can refer to the first radio button in the set like this:

window.document.the_form.age[0]

JavaScript also creates an array for the options in each pull-down menu and scrollable list. Here's how you could access the second option in a pull-down menu named gender:

window.document.the_form.gender.options[1]

These are just two of JavaScript's automatically created arrays. Browsers also automatically create an array of all the image objects on a web ...

Get The Book of JavaScript, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.