9_数组.html 670 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. </head>
  9. <body>
  10. <script>
  11. var a = [1, 2, 3, 4, 5, 6]
  12. console.log(a)
  13. var b = ['小明', 123, true]
  14. console.log(b)
  15. /* 数组里面存放任何的值 */
  16. var d = new Array()
  17. d[0] = 11
  18. d[3] = 22
  19. d[4] = 55
  20. console.log(d[2])
  21. //empty 空占位符
  22. var x = [666, 777, 888]
  23. x[1] = 999
  24. console.log(x)
  25. for (var i = 0; i < x.length; i++) {
  26. console.log(i)
  27. }
  28. </script>
  29. </body>
  30. </html>