js找出列表中最大/最小元素

根据MDN官方的定义:可以使用reduce:

const a = Array(100).fill(Math.random());

let max = a.reduce( (a,b)=>{ return Math.max(a,b)})

或者使用速度更快的一种方法:

let max =  Math.max(...a)

但是由于max函数参数的限制,这种方法中a列表的元素个数不能太多

原文地址:https://www.cnblogs.com/lyzz1314/p/15418848.html