其实你已经没有吧它当成array来使用了,length当然没用啦。var aaa = new Array();
aaa['a'] = '1';
aaa['b'] = '2';
var count=0;
for (i in aaa){ count++}
alert(count)
aaa['a'] = '1';
aaa['b'] = '2';
var count=0;
for (i in aaa){ count++}
alert(count)
alert(count)就是这个阿但是也可以Array 对象
在 JScript 中,对象作为数组处理,数组作为对象处理。数组的下标完全等价于对象的属性,可以按数字引用(如果对其指定了名称,则也可以按名称来引用)。要创建一个新数组,请使用 new 运算符和 Array() 构造函数,如下例所示。
var theMonths = new Array(12) {
theMonths[0] = "一月";
theMonths[1] = "二月";
theMonths[2] = "三月";
theMonths[3] = "四月";
theMonths[4] = "五月";
theMonths[5] = "六月";
theMonths[6] = "七月";
theMonths[7] = "八月";
theMonths[8] = "九月";
theMonths[9] = "十月";
theMonths[10] = "十一月";
theMonths[11] = "十二月";
}在使用 Array 关键字来创建数组时,JScript 在该数组中包括了一个只写的 length 属性,用来记录数组中的项数。如果您没有指定一个数值,则 length 被设置为 0,且数组没有任何项。如果您指定了一个数值,则 length 被设置为该数值。如果您指定了多个参数,则这些参数将作为数组的项,并将参数的个数指定给 length 属性,如下例所示。该示例与上一节示例等价。
var theMonths = new Array("一月", "二月", "三月", "四月", "五月", "六月",
"七月", "八月", "九月", "十月", "十一月", "十二月");对于使用 Array 关键字创建的数组,当给数组添加元素时,JScript 将自动更改 length 的数值。
var count=0;
for (bbb in aaa) {
zzz = bbb;
count++;
}