lyd447113735

 

在JavaScript中有多种第一数组的方式

 

 

 <script>
        var arr1 = ["one", "two", "three"];
        document.write("方法一:"+arr1);
    </script>

    <br>

    <script>
        var arr2 = new Array("one","two","three");
        document.write("方法二:"+arr2);
    </script>

    <br>

    <!--动态赋值,不用固定数组的大小-->
    <script>
        var arr3 = new Array();
        arr3[0] = "one";
        arr3[1] = "two";
        arr3[2] = "three";
        document.write("方法三:"+arr3);
    </script>

 

 

 

三种不同的实现方法的实现效果是一样的

 

分类:

技术点:

相关文章:

  • 2021-10-14
  • 2021-12-08
  • 2021-10-22
  • 2021-10-12
  • 2021-11-14
  • 2021-11-14
  • 2021-10-14
  • 2021-11-15
猜你喜欢
  • 2021-11-14
  • 2021-11-14
  • 2021-11-14
  • 2021-12-08
  • 2021-10-16
  • 2021-11-30
  • 2021-11-14
相关资源
相似解决方案