Blogger Information
Blog 10
fans 0
comment 0
visits 6473
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
【数组】-JavaScript
迷途何必知返
Original
725 people have browsed it
<!DOCTYPE html>
<html>
<head>
<title>数组</title>
</head>
<body>
<!-- 数组:方便存取和减少内存的占用 
     作用:使用单独的变量名来存储一系列的值 -->
    <!-- 下标(房间号)从零开始 数组的总数就是最后一个下标加一 -->
<!-- <script type="text/javascript">
     //创建数组 通过操作符和构造函数来创造数组
     //三种方法实例
     var a=new Array()
         a[0]='PHP';
         a[1]='HTML';
         a[2]='WEB';
     var a=Array('PHP','HTML','WEB');
     var a=['PHP','HTML','WEB']
    // 访问数组 通过指定的数组名,以及对应的下标(索引号码)来访问数组。
    document.write(a[1])
</script> -->

    <!-- 以下是二维数组的创建方法 -->
<!-- <script type="text/javascript">
     var b=new Array('PHP','HTML','WEB');
     b[0]=new Array(1,2,3,4);
     b[1]=new Array('张三','李四','王二');
</script> -->

<!-- 学习章节小练习案例 :创建一份二维数组,然后改变他对应的值-->
<!-- <script type="text/javascript">
   var box=new Array(
       new Array(11,12),
       new Array(13,14),

   )
       document.write(box[1][1])
       document.write('<br>')
       //改变数组内部的值 赋值100改变
       box[1][1]=100;
       document.write(box[1][1])
</script> -->

<!-- for in 循环 : 循环输出数组中所有的元素-->
<script type="text/javascript">
      var week=new Array()
      week[0]='PHP'
      week[1]='PHP1'
      week[2]='PHP2'
    for (x in week){
      document.write(week[x]+'<br>')
    }
</script>
</body>
</html>


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post