Home >Web Front-end >JS Tutorial >Advanced JavaScript (10) Array Array Detailed Explanation
//Create an array.
var arr1 = new Array();
//Create an array and specify the length. Note that it is not the upper limit, but the length.
var a = new Array(5);
//Create an array and assign values.
var a = new Array(["b", 2, "a", 4,]);
//Abbreviation for creating an array and assigning values. Note that the square brackets here do not mean that they can be omitted.
var a = ["b", 2, "a", 4,];
var a = new Array(5); // refers to creating an array with a length of 5
var a = new Array([5]); // refers to creating an array with a length of 1, and the first digit is 5
##
var t2=new Array(); t2[0]=1; t2[1]=2; test2(t2); //传地址(数组) function test2(var2) { for(var i=0;i<var2.length;i++) { var2[i]=var2[i]+1; } } for(var i=0;i<t2.length;i++) { alert(t2[i]); }