JavaScript:多种定义数组的方式
在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>
三种不同的实现方法的实现效果是一样的


浙公网安备 33010602011771号