JS中可以通过delete删除数组元素,但是删除后数组的大小不会改变
<script type="text/javascript"><!-- var days = ["Sunday","Monday","Tuesday","Wednesday", "Thursday","Friday","Saturday"]; document.write("Number of days:"+days.length); delete days[4]; document.write("<br />Number of days:"+days.length); //--> </script>
输出结果
Number of days:7 Number of days:7