javascript reduce method stack overflow

JavaScript
var arr = [1,2,3,4,5,6];
arr.reduce(function(p,n){
 return p+n;
},0);
// Output 21
Source

Also in JavaScript: