Search code examples
javascriptjquerymultidimensional-arrayhandsontable

What is a [[ param1, param2 ... ]] structure in javascript?


I'm working with handsontable, but am not knowledgeable about JavaScript. I have:

$container.handsontable({
              startRows: 8,
              startCols: 6,
              rowHeaders: true,
              colHeaders: true,
              minSpareRows: 1,
              contextMenu: true,
              afterChange: function (change, source) {
                if (source === 'loadData') {
                  console.log(change);
                }

When I look in the console I see:

  [[4, "notes", "PLEASE SET", ""]]

This does not look like a standard object. what is it and how can I access its parameters?


Solution

  • This is an array where the first element is an array containing 4 elements.

    Try this in your browser JavaScript console (press F12, then go to console) or in jsconsole.com:

    var arr =  [[4, "notes", "PLEASE SET", ""]]; // Initialize the array
    
    console.log (arr[0]);    // [4, "notes", "PLEASE SET", ""]
    console.log (arr[0][0]); // 4
    console.log (arr[0][1]); // "notes"
    console.log (arr[0][2]); // "PLEASE SET"
    console.log (arr[0][3]); // ""
    console.log (arr[0][4]); // undefined
    console.log (arr[1]);    // undefined
    console.log (arr[1][0]); // undefined