Skip to content

获取取数组的最大值(ES5、ES6)

  1. max
js
const arr = [1, 2, 3, 4, 5];
const max = Math.max(...arr);
console.log(max); // 输出 5
  1. for
  2. reduce + max