title: Is there a better way to do partial sums of array items in JavaScript?
body: <p>I wonder if there is a better way of generating a better performing solution for partial sums of an array.</p>
  
  <p>Given an array say <code>x = [ 0, 1, 2, 3, 4, 5 ]</code>, I generated sub-arrays of the items, and then computed the sum of each array which gives: </p>
  
  <pre><code>[ 0, 1, 3, 6, 10, 15 ]
  </code></pre>
  
  <p>So the full code is:</p>
  
  <pre><code>x.map((y,i)=&gt;x.filter((t,j)=&gt;j&lt;=i))
   .map(ii=&gt;ii.reduce((x,y)=&gt;x+y,0))
  </code></pre>
  
  <p>I wonder if flat map or some other array method will have a solution that does not require expanding each subarray.</p>