January 2001
Beginner
312 pages
6h 4m
English
Earlier, you read that the length of an array is hidden away within the property length. length is a property of the array, and though it may be hidden, it isn't beyond your reach.
To find out how many elements are in the days_of_week array, you can use the following:
days_of_week.length
In the following example, an alert box is used to show this value:
<html>
<head>
<title>A Simple Page</title>
<script language="JavaScript">
<!-- Cloaking device on!
var days_of_week = new
Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
alert(days_of_week.length);
// Cloaking device off -->
</script>
</head>
<body>
</body>
</html>
The output from this example is shown in Figure 5.5.
Read now
Unlock full access