123456789101112131415161718192021222324252627282930313233 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- </head>
- <body>
- <script>
- // 数组 存放多个值 用中括号包裹 逗号间隔
- var arr = [1,2,3,4,5,6,7,8,9];
- // 多维数组
- var arr1 = [1,2,3,['a','b',["hello","world"]]]
- console.log(arr);
- // 获取数组当中制定位置的值 (数组名[索引])
- // 通过索引获取数组当中的值
- // 索引从0开始 索引标记着数组顺序
- console.log(arr[2])//获取第三个值
- console.log(arr[0])//获取第一个值
- // 多维度数组获取值
- // 获取arr1中 a
- console.log(arr1[3][0])//获取a
- console.log(arr1[3][2][0])//获取hello
- var arr2 = [2,"a",undefined,null];
- </script>
- </body>
- </html>
|