title: Multi-dimensional associative arrays in JavaScript
body: <p>There is the following query results: (key1 and key2 could be any text)</p>
  
  <pre><code>id   key1     key2     value
  
  1    fred     apple    2
  2    mary     orange   10
  3    fred     banana   7
  4    fred     orange   4
  5    sarah    melon    5
  ...
  </code></pre>
  
  <p>and I wish to store the data in a grid (maybe as an array) <strong>looping</strong> all the records like this:</p>
  
  <pre><code>         apple    orange   banana  melon
  fred        2        4         7     -
  mary        -        10        -     -
  sarah       -        -         -     5
  </code></pre>
  
  <p>In PHP this would be really easy, using associative arrays:</p>
  
  <pre><code>$result['fred']['apple'] = 2;
  </code></pre>
  
  <p>But in JavaScript associative arrays like this doesn't work.
  After reading tons of tutorial, all I could get was this:</p>
  
  <pre><code>arr=[];
  arr[1]['apple'] = 2;
  </code></pre>
  
  <p>but <code>arr['fred']['apple'] = 2;</code> doesn't work.
  I tried arrays of objects, but objects properties can't be free text.
  The more I was reading tutorials, the more I got confused...</p>
  
  <p>Any idea is welcome :)</p>