1.使用length清空数组:
代码如下 复制代码
<script>
var arr1 = ['aaa','bbbb','http://www.111cn.net'];
alert(arr1);
arr1.length = 0;
alert(arr1); //数组为空
</script>
更多详细内容请查看:http://www.111cn.net/wy/js-ajax/56950.htm
2.使用length截短数组:
代码如下 复制代码
<script>
var arr1 = ['aaa','bbbb','c','d','e'];
arr1.length = 3;
alert(arr1); //截断数组aaa,bbbb,c
</script>