title: Convert javascript object of one type into another
body: <p>I need to convert a JavaScript object of one type: </p>
  
  <pre><code>object1: [{"a":"value1", "b":"value2", "c":"value3"}, {"d":"value4","e":"value5","f":"value6"}] 
  </code></pre>
  
  <p>To another type of object: </p>
  
  <pre><code>object2 : {"value1":["value1", "value2", "value3"], "value4":["value4","value5","value6"]}
  </code></pre>
  
  <p>I tried to convert it using this function:</p>
  
  <pre><code>function toObject(arr) {
     var rv = {};
     for (var i = 0; i &lt; arr.length; ++i) {
        rv[i] = arr[i];
     }
     return rv;
  }
  </code></pre>
  
  <p>but I'm getting numerical indexes ([0], [1]) instead of "value1" and "value4". Could you please give me some hint how can I do the conversion from object1 to object2. Thanks. </p>