title: how to create a multi dimensional array in javascript inside a jquery each loop?
body: <p>I have this example:</p>
  
  <pre><code>var name;
  var id;
  var array = []; 
  
  $.each(data, function(index, element) {
  name = element.name;
  id = element.id;
  array[id] = name;
  &lt;a href="#" onClick="myFunction(array)"&gt;send&lt;/a&gt;
  console.log(array);
  });
  </code></pre>
  
  <p>In this case <code>.each</code> will iterate 5 times and <code>id</code> will become <code>1, 2, 3, 4, 5</code> and <code>name</code> will change to five names</p>
  
  <p>i would like to create a multidimensional array or an object that will look like this:</p>
  
  <pre><code>[1:name1] for the first iteration
  [2:name2] for the second on
  ...
  </code></pre>
  
  <p>the pass each pair of values to the <code>myFunction</code> function
  and inside that function to have access to the array values:</p>
  
  <p>function myFunction(array){
      // alert the key and value
  }</p>
  
  <p>Any ideas how can I accomplish this scenario?</p>