reduce()

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

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

 

posted @ 2016-10-20 23:57  papering  阅读(155)  评论(0编辑  收藏  举报