0

I would like to ask on how to write Multidimensional Array in jQuery ?

its oky if its in basic syntax, im still new to jQuery.

Justin Johnson
  • 30,978
  • 7
  • 65
  • 89
user210950
  • 1
  • 1
  • 1
  • Similar post: "Array functions in jQuery" at http://stackoverflow.com/questions/477700/ – o.k.w Nov 14 '09 at 08:35

2 Answers2

2

Its Javascript, not JQuery that handles the arrays, so what you really want is a tutorial on multidimensional arrays in Javascript.

Here is a good one.

Basically you define one array, then reference it inside another array. For example:

var columns = new Array(3);
var rows = new Array(4);
rows[0] = columns;

This can then be accessed as follows:

rows[0][0]
Soviut
  • 88,194
  • 49
  • 192
  • 260
1

there are no multidimensional arrays in javascript, but you can have an array whose elements are arrays

  square = [
      [1, 2, 3],
      [4, 5, 6],
      [7, 8, 9]
  ]

arrays don't have to be of the same length

  triangle = [
      [1, 2, 3],
      [4, 5],
      [6]
  ]

you can mix array and non-array elements

   wookie = [
        head,
    [hand, hand],
       belly,
     [foot, foot]
  ]
user187291
  • 53,363
  • 19
  • 95
  • 127