title: How can I convert an indexed JavaScript object to an array of objects?
body: <p>I have an object that looks like this:</p>
  <pre><code>obj = {
  &quot;price&quot;: {0: &quot;10.00&quot;, 1: &quot;15.00&quot;, 2: &quot;6.00&quot;},
  &quot;serialNumber&quot;: {0: 1000, 1: 2000, 2: 3000}
  }
  </code></pre>
  <p>I'm trying to convert it into an array of objects so I can do <code>obj.map((obj, idx)=&gt;{//display obj.price and obj.serialNumber//})</code>, so I want to convert <code>obj</code> into an array like this:</p>
  <pre><code>obj_array = [{&quot;price&quot;:&quot;10.00&quot;, &quot;serialNumber&quot;: 1000}, {&quot;price&quot;:&quot;15.00&quot;, &quot;serialNumber&quot;: 2000},{&quot;price&quot;:&quot;6.00&quot;, &quot;serialNumber&quot;: 3000}]
  </code></pre>
  <p>I initially used <code>array = Object.values(obj['serialNumber'])</code> to just get serialNumber, but due to the way <code>Object.values</code> works, I can't just do <code>array = Object.values(obj['serialNumber','price'])</code> to get both. The values() function will ignore the serialNumber field and just make an array of prices. Any help would be appreciated!</p>