时间:2021-07-01 10:21:17 帮助过:17人阅读
1.使用length清空数组:
代码如下:
<script>
var arr1 = ['aaa','bbbb','//www.gxlcms.com'];
alert(arr1);
arr1.length = 0;
alert(arr1); //数组为空
</script>
2.使用length截短数组:
代码如下:
<script>
var arr1 = ['aaa','bbbb','c','d','e'];
arr1.length = 3;
alert(arr1); //截断数组aaa,bbbb,c
</script>