Declaring a two-dimesional array in javascript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ms_chika

    Declaring a two-dimesional array in javascript

    Hi to all,
    I have this problem in declaring a two-dimesional
    array, how will i declare such array with unknown number of rows?

    Your help will be very much appreciated. Thanks in advance.



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
  • Lee

    #2
    Re: Declaring a two-dimesional array in javascript

    ms_chika said:[color=blue]
    >
    >Hi to all,
    >I have this problem in declaring a two-dimesional
    >array, how will i declare such array with unknown number of rows?
    >
    >Your help will be very much appreciated. Thanks in advance.[/color]

    Javascript doesn't support two-dimensional arrays, but on the other
    hand, you don't need to declare the number of elements in an array,
    either.

    var myArray=new Array();
    myArray[237]=new Array();
    myArray[237][12]="Hello, world!";

    Comment

    • ms_chika

      #3
      Re: Declaring a two-dimesional array in javascript

      oh i see, how about this one ,another question. I have 3
      two-dimensional array, i want to merge these 3 arrays so that it will
      become only 1 two-dimensional array. Is it possible? If it is, how will
      i dot that?




      *** Sent via Developersdex http://www.developersdex.com ***
      Don't just participate in USENET...get rewarded for it!

      Comment

      • Markus Ernst

        #4
        Re: Declaring a two-dimesional array in javascript

        ms_chika wrote:[color=blue]
        > oh i see, how about this one ,another question. I have 3
        > two-dimensional array, i want to merge these 3 arrays so that it will
        > become only 1 two-dimensional array. Is it possible? If it is, how
        > will i dot that?[/color]

        Have you tried something like:

        j=target_array. length;
        for (var i=0; i<source_array. length; i++) {
        target_array[j] = source_array[i];
        j++;
        }

        ?
        HTH
        Markus


        Comment

        • Mick White

          #5
          Re: Declaring a two-dimesional array in javascript

          ms_chika wrote:[color=blue]
          > Hi to all,
          > I have this problem in declaring a two-dimesional
          > array, how will i declare such array with unknown number of rows?
          >
          > Your help will be very much appreciated. Thanks in advance.
          >[/color]

          var prem=
          [["Arsenal",12,3, 2],["Chelsea",12,5, 0],["Fulham",6, 6,6],["Tottenham",4,4 ,8]];

          prem[1][0] =="Chelsea" //true

          Mick

          Comment

          • ms_chika

            #6
            Re: Declaring a two-dimesional array in javascript

            Thanks a lot, i got it. =)



            *** Sent via Developersdex http://www.developersdex.com ***
            Don't just participate in USENET...get rewarded for it!

            Comment

            Working...