1234567891011121314151617181920212223242526272829303132 |
- <!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>
- // 索引 0 1 2 3
- // 数值 1 2 3 4
- //length 数组的长度
- // var a = [1,2,3,4]
- // //数组中可以保存任意类型的数据。
- // var b = [111,true,'hahahah']
- // console.log(b)
- //如果在括号内写上长度 那么 就算数据不足数组长度 数组长度也为输入的数值 其他位置为empty
- var c = new Array(5)
- c[0] = 'hahhah'
- c[1] = 'xixixi'
- c[2] = 'heheheh'
- console.log(c)
- for(var i=0;i<c.length;i++){
- console.log(c[i])
- }
- </script>
- </body>
- </html>
|