Posted in Javascript onMarch 20, 2015
本文实例讲述了JavaScript删除数组元素的方法。分享给大家供大家参考。具体分析如下:
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
希望本文所述对大家的javascript程序设计有所帮助。
JavaScript删除数组元素的方法
- Author -
work24声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@