title: Create named arrays from JSON
body: <p>I'm fetching data from a MySQL DB and encode it as JSON before passing it to a Javascript class. The data will be used to display charts. The chart does need arrays, and I'm looking for a method to create the needed arrays from my JSON object without creating every array manually and pushing values into it.</p>
  
  <p>My Object looks like this:</p>
  
  <pre class="lang-js prettyprint-override"><code>var myJSON = [
          {"name1": "value11", "name2":"value21", "name3": "value31"},
          {"name1": "value12", "name2":"value22", "name3": "value32"},
          {"name1": "value13", "name2":"value23", "name3": "value33"}
  ]
  </code></pre>
  
  <p>And I would like to look it like this:</p>
  
  <pre class="lang-js prettyprint-override"><code>var myData = {
  "name1": ["value11", "value12", "value13"],
  "name2": ["value21", "value22", "value23"],
  "name3": ["value31", "value32", "value33"],
  }
  </code></pre>
  
  <p>I know how I could create the needed arrays and push the values into them, but I am hoping there is a more elegant solution to this. I have looked into the Map function and familiarized myself with Object.keys and Object.entries but I just can't seem to figure it out. </p>
  
  <p>Basically I think this can and should be solved in javascript, but I also tagged the question with Mysql/PDO because I could fetch the data differently if that is an option. </p>
  
  <p>I've been trying since friday, hoping there is an elegant solution, but to no avail. Any help would be greatly appreciated. </p>