I’m reading some values from a local database using ado in IE8 and generating a 2d array. I want the first index of this array to be the field and the second to be the row. For this reason, even when there is only one field or one row, I want a 2 dimensional array. The following code adequately describes the process I’m using to create the array:
function test() {
var a = new Array(1);
alert(a.length); // 1
for (var i=0; i<10; i++)
a[0,i] = i;
alert(a.length); // 10
}
Before the loop, the array length is 1. Afterward it is 10. This means when I want a 1xn array, I get a vector of length n.
I don’t even have access to other browsers to see if this happens elsewhere. I’m very constrained in my tools, but that’s another story.
Thanks in advance for any help.
Matt
You need this:
Because Javascript doesn’t have true multidimensional arrays, you’ll have to access the second array with
a[0][i], nota[0, i]. This is because you’re really creating an array of arrays.