1、数组的长度:
var arr1:Array = ["1","2","3","4"]; delete arr1[0]; trace(arr1.length); //输出4(虽然delete可以删除数组中的元素,但并不改变数组的长度) var arr2:Array = ["1","2","3","4"]; arr2.splice(0, 1); trace(arr2.length);//输出3(splice在删除数组元素的同时,还会改变数组的长度) var arr3:Array = []; trace(arr3.length);//输出0 arr3[3] = 1; trace(arr3.length);//输出4(用中括号+数组下标的方式给数组元素赋值时,数组的长度变为最大下标+1) var arr4:Array = []; arr4["字符串key"] = "xxxxx"; trace(arr4.length);//输出0(字符串下标并不会改变数组的长度) arr4["5"] = "xxxxx"; trace(arr4.length);//输出6(如果字条串是纯数字,会被当成数字来处理) arr4["010"] = "xxxxx"; trace(arr4.length);//输出6(不同与int("010")==10,数组的下标并不会进行int()转换,arr4["010"] = "xxxxx"的结果就是arr4中多了一个"010"的key,而arr4的长度不变)
原文:http://blog.csdn.net/risemypassion/article/details/43561759