js 數組清空 方法 匯總
阿新 • • 發佈:2018-11-05
body bsp size ava oct round pan span 清空
<!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 數組清空 方法 匯總