title: Applying a function to each object in a JavaScript array
body: <pre><code>[ {name:'hi',data:'1,2,3,4,5'} , {name:'hello',data:'5,4,3,2,1'} ]
  </code></pre>
  
  <p>What I need is to apply a split on <code>data</code> of each object in array so that the result would be:</p>
  
  <pre><code>[ {name:'hi',data:[1,2,3,4,5]} , {name:'hello',data:[5,4,3,2,1]} ]
  </code></pre>
  
  <p>I know I can loop through the array using <code>for each</code> and produce a new array, but is there a better, faster method?</p>
  
  <pre><code>var arr = [{
      name: 'hi',
      data: '1,2,3,4,5'
  }, {
      name: 'hello',
      data: '5,4,3,2,1'
  }];
  
  var new_arr = [];
  for (i in arr) {
      var temp = {};
      temp.name = arr[i].name;
      temp.data = arr[i].data.split(',');
      new_arr.push(temp);
  }
  </code></pre>