Accumulated sum of arrays?

  node.js, question

HI, I have a requirement. Now I have an array


Required output


That is, each item n of the newly output array is the sum of the first n items (including n) of the corresponding old array. so, what is the best way?

Ps: The code should be elegant ~

var arr = [1, 2, 3, 4, 5];
 var newArr = [];
 arr.reduce(function (prev, next) {
 Push (prev plus next);
 Return prev plus next;
 }, 0);

Php finds the corresponding reduce method.