Reduce
javascript
JavaScript
array.reduce((buffer, item, index, originalArray) => {/* process */}, bufferInit);
// examples :
[6, 3, 8].reduce((acc, item) => acc + item, 0);
// two following line do the same thing
[6, 3, 8].reduce((buff, item) => (buff.push(Math.sqrt(item)), buff), []);
[6, 3, 8].reduce((buff, item) => {buff.push(Math.sqrt(item)); return buff;}, []);