[thelist] 2-dimensional array in jscript

aspscript at canada.com aspscript at canada.com
Thu Sep 2 16:24:52 CDT 2004


I don't always know the what the upper bound of the
array will be.  So since it is possible to declare a
boundless one-dimensional array like this:

var x = []

... I was hoping I could do the same with a two
dimensional array. But it's not that big a deal as I
can always just set some upper bound beyond what I am
sure to need and go from there.  So, like your example,
I can always do this:

var arr=[],
  i=100;
  do
  arr.push([]);
  while(0<--i);

And that will be able to handle from arr[1][1] to
arr[100][???], which should be enough.


On Thu, 2 Sep 2004 18:53:45 +0200, liorean wrote:

<snip>
> 
> Take this example, for instance:
>     var
>         arr=[],
>         i=3;
>     do
>         arr.push([]); // Add element to array, assign
a
> new array to it
>     while(0<--i); // And repeat two times, generating
a
> three element array;
> 


More information about the thelist mailing list