首页 > 代码库 > reduce()

reduce()

Professional.JavaScript.for.Web.Developers.3rd.Edition.Jan.2012

var value = http://www.mamicode.com/[1,2,3,4,5];
var sum = value.reduce(function(prev, cur, index, array){
    return prev+cur;
});
alert(sum);

 

reduce()