<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
// length获取长度
var arr1 = [1,2,3,4]
console.log(arr1.length)
// 清空数组
arr1.length = 0
console.log(arr1)
// 索引0,1,2,3
var arr2 = ["aa","bb","cc"]
console.log(arr2[0],arr2[1],arr2[2])
// 修改值
arr2[0] = "666666"
console.log(arr2[0])
// 遍历复制
var arr4 = []
var arr3 = [3,4,5,6,7,8]
for(var i = 0;i<arr3.length;i++){
arr4[i] = arr3[i]
}
console.log(arr4)
arr4[0] = "aaaaaaaaaaaaa"
console.log(arr3,arr4)
</script>
</body>
</html>
标签:console,log,--,JavaScript,length,arr2,arr1,var,基本操作
From: https://blog.csdn.net/weixin_58694594/article/details/142319978