How to define a two-dimensional array in JavaScript.

Source: Internet
Author: User
Tags array definition
How to define a two-dimensional array in JavaScriptCategory: JS JavaScript two-dimensional array of arrays JS cyclic array assignment 2011-12-14 11:14 136 people read comments (0) Collection report

JavaScript two-dimensional array definition [a]:
JavaScript code <script> var a=new Array ();         A[1]=new Array ("A", "B"); </script>


--------------------------------------------------------------------------------
JavaScript two-dimensional array definition [II]:
  JavaScript code <script   language= "JavaScript" >         <!--         var   a    =   new   array ();         a[0]    =   new   array ("A", "B");         a [1]   =   new   array ("C", "D");         alert (a[1][1]);         //-->          </script>    

 
  
--------------------------------------------------------------------------------
JavaScript two-dimensional array definition [three]: »
  JavaScript code var   arr   =    new   array ([1,2,3],[4,5,6],[7,8,9,10]);          for (Var   e   in   arr)    alert (Arr[e]);            


--------------------------------------------------------------------------------
JavaScript two-dimensional array definition [Four]: »
Declare an array first: &NBSP;&NBSP;&NBSP
   JavaScript code var A=new   arrray _num);         a[first_num]=new   array (number);          a[first_num]=new   array (number);              //first_name is the dimension,         // Number can come in accordance with your needs.          //This can create multidimensional arrays. &NBSP;&NBSP;&NBSP;&NBSP;&NBSP
 

--------------------------------------------------------------------------------
JavaScript two-dimensional array definition [Five]  »
  JavaScript code <script>         T=new    array;         T[1]=new   Array;         t[1][0]= "A";         t[1][1]= "B";         alert (t[1][0]);         </script>   


--------------------------------------------------------------------------------
JavaScript two-dimensional array definition [VI] »
  JavaScript code <script>         var   result    =   new   array (New   array ("1", "1111"),                new   array ("2", "2222") ,    new   array ("3", "3333"),                new   array ("4", "4444");          for (var   i=0;i<   result.length;i++) {         alert (result[i][0]+ "|") +RESULT[I][1]);         }         </ script>    

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.