As you probably know, javascript handles objects in odd ways compared
to java and other languages. It is possible to have an array grow
dynamically in Javascript. Here is a code snippit:
<script type="text/javascript" language="JavaScript">
<!-- Hide this script from incompatible browsers!
var stuff = new Array(3)
stuff[1] = "hello"
stuff[2] = 27
stuff[3] = 8.5
stuff[5] = "element number 5"
for( i = 1; i <= 5; i++){
document.writeln("stuff[" + i + "] = " + stuff[i]);
}
-->
------------------------------------------------
Here is the output:
stuff[1] = hello
stuff[2] = 27
stuff[3] = 8.5
stuff[4] = undefined
stuff[5] = element number 5
-------------------------------------------------
Notice that while we define the array as having indices 1 to 3, we
extend it by assigning a value to element number 5.