[Solved] How to create a multi dimensional array in jQuery?


In javascript there are 2 type of arrays: standard arrays and
associative arrays

  • [ ] – standard array – 0 based integer indexes only
  • { } – associative array – javascript objects where keys can be any strings

So when you define:

var arr = [ 0, 1, 2, 3 ];

you are defining a standard array where indexes can only be integers.

So you can write this object

var obj = {
    'aaa': 'ccsdfccc',
    'bb': 'aaddsaaaa',
    '1': {
        'three': 'sdsds',
        'four': 'eesdsee'
    },
    '2': {
        'one': 'dcvcdd',
        'two': 'eeee'
    }
}

and then use it like obj['1'].three

1

solved How to create a multi dimensional array in jQuery?