JS练习_reduce()求数组中最大值或最小值

// 获取数组中最大值
var arr = [134798, 3478973, 12, 345, 355, 425, 1342356, 3425566, 7908798]
var max = arr.reduce(function (prev, next) {
    return Math.max(prev, next)    // Math.min(prev, next)
}, 0)
console.log(max)
posted @ 2021-09-12 17:33  博客zhu虎康  阅读(290)  评论(0编辑  收藏  举报