This article is mainly on the JS processing itself can not define a two-dimensional array of methods to introduce, the need for friends can come to the reference, hope to read everyone has helped
Code as follows: Var a= new Array (new array (1,2), new array (' B ', ' C ')); document.write (a[1][1)); plainly, is to use a For loop to define a two-dimensional array! ? <script language= "javascript" type= "Text/javascript" > function array_2 (nrow,ncolumn) { var array1=new Array (); Definition one-dimensional array for (i=0;i<nrow;i++) { //Each child element is also defined as an array array1[i]=new Array (); //---------------------------------------- for (n=0;n<ncolumn;n++) { &NB Sp array1[i][n] = '; At this point Aa[i][n] can be viewed as a two-level array } //------------------------------------ -- } return array1; } var ar ray_2= array_2 (3,2); ARRAY_2[0][1] = 1; ARRAY_2[0][2] = 2; Array_2[1][1] = 3; Array_ 2[1][2] = 4; document.write (array_2[1][2)); </script> //Dashed section can also be used JS The push () method of the array built-in object is implemented because Arr1.push (ARR2) will add the entire array arr2 as an element to the ARR1 array, so the for loop in the dashed line can be completely replaced with the following statement: Array1[i].push (New Array (Ncolumn)); Today also found that this definition can also be made into two-dimensional arrays; the code is as follows: Var a= new Array (new array (1,2), new array (' B ', ' C ')); document.write (a[1][1]); PS: Note the difference between push and concat! The Push method adds these elements in the order in which the new elements appear. If one of the arguments is an array, the array is added as a single element to the arrays. If you want to merge elements from two or more arrays, use the Concat method. The concat method returns an Array object that contains a connection to the array1 and any other items provided. Items to add (item1 ... itemn) are added to the array in Left-to-right order. If an item is an array, add its contents to the end of the array1. If the item is not an array, it is added to the end of the array as a single array element. VERY good!!!