Showing All Elements

Finally, let's look at a quick and simple way to list the values of all the elements in an array. This is done by simply using the name of the array. Therefore, to return all the elements of days_of_week and place them in an alert box, you can use the following (see Figure 5.6 for output):

Figure 5.6. Alert box displaying the values for all the elements in the array days_of_week.

 <html> <head> <title>A Simple Page</title> <script language="JavaScript"> <!-- Cloaking device on! var days_of_week = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday", ...

Get JavaScript™ 1.5 by Example 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.