js reduce

var arr = [3,9,4,3,6,0,9];

var sum = arr.reduce(function (prev, cur) {
    console.log(prev,cur)
    return prev + cur;
},0);// 0 是 初始值
posted @ 2020-02-14 14:33  霜末之冬  阅读(129)  评论(0编辑  收藏  举报