前端学习记录
作者:互联网
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
</body>
</html>
<script>
var arr1=[1,2,3,4]
var arr2=['a','b','c',3214,351,{name:'xiaoming'
,age:12,hobbies:['英雄联盟','王者荣耀']}
,[1,2,3]]
var arr3 = new Array(9,3,0)
console.log(arr3)
var arr4 = []//推荐这样使用更简单
console.log(arr2.length)
console.log(arr3.length)
arr2[2]='d'
console.log(arr2)
arr3=[11]='arr3d'
console.log(arr3)
console.log(arr1)
arr1.push('d')
console.log(arr1)
arr1.pop()//从最后删除
console.log(arr1)
arr1.shift()//从前面删除
console.log(arr1)
arr1.unshift(0)//从前面增加
console.log(arr1)
console.splice(1,0,'a','b')
console.log(arr1)//任何位置增加删除
//typeof
var a=1 ,b='1' , c=true,d=null
console.log(typeof a) //语法糖
console.log((e.length))
if(typeof e=="object"&&(e.length||e.length==0)){
console.log('e is Array')
}
console.log(Array.isArray(e))
//if (Array.isArray(e)){
//console.log('是数组')
//}else{
// console.log('不是数组')
//}
</script>
标签:console,log,记录,前端,学习,length,arr3,arr1,var 来源: https://www.cnblogs.com/huzhibolibrary/p/15646864.html