首页 > 编程语言 > 详细

js 数组清空 方法 汇总

时间:2018-11-05 18:53:45      阅读:134      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>js清空数组的方法</title>
    </head>
    <body>
        <script type="text/javascript">
            let aa= [1,2,3,4]
            // 方法一
            aa.splice(0)
            console.log(aa);
            // 方法二
            aa = [];
            console.log(aa);
            // 方法三
            aa.length = 0;
            console.log(aa);
            
        </script>
    </body>
</html>

 

js 数组清空 方法 汇总

原文:https://www.cnblogs.com/mengfangui/p/9910360.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!