title: Create an array of mixed objects in Javascript
body: <p>I am trying to create an array like this one:</p>
  
  <pre><code>["Apple",{1: "Pie", 2: "Dumpling", 3: "Cider"}, "Banana", {1: "Bread", 2: "Republic"}]
  </code></pre>
  
  <p>starting from an array of just:</p>
  
  <pre><code>["Apple", "Banana"]
  
  // &lt;input id="Apple"... data-makes="Pie,Dumpling,Cider"&gt; 
  // &lt;input id="Banana" ... data-makes="Bread,Republic"
  
  var output = [];
  var fruits = ["Apple", "Banana"];
  for (i=0; i &lt; fruits.length; ++i)
  {
    members = document.getElementById(fruits[i]).getAttribute("data-makes");
    tmp = members.split(",");
    for (k=0; k &lt; tmp.length; ++k)
    {
      output[i][k+1] = tmp[k];
    }
  }
  </code></pre>
  
  <p>Everything I've tried so far is either invalid syntax or makes the initial array <em>undefined</em>.</p>