<!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 数组清空 方法 汇总
猜你喜欢
转载自www.cnblogs.com/mengfangui/p/9910360.html
今日推荐
周排行