释放双眼,带上耳机,听听看~!
//需求:查找数组中的最大值
let arr = [10, 20, 7, 88, 99, -10, 56];
//以前的做法
// 最大值
let max = -Infinity;
for (let i = 0; i < arr.length; i++) {
if (arr[i] > max) {
max = arr[i]
}
}
console.log(max);
// 最小值
let min = Infinity;
for (let i = 0; i < arr.length; i++) {
if (arr[i] < min) {
min = arr[i]
}
}
console.log(min);
//现在的做法:
// 最大值
let maxValue = Math.max.apply(Math, arr);
console.log(maxValue);
// 最小值
let minValue = Math.min.apply(Math, arr);
console.log(minValue);
内容投诉









![[前端开发] MUI框架详解-全面讲解MUI框架使用](https://www.bloglab.cn/wp-content/uploads/thumb/2018/12/fill_w372_h231_g0_mark_80e5f34e03334950b3a4cb73bf4262dd.jpg)


![[MySQL] MySQL面试指南](https://www.bloglab.cn/wp-content/uploads/2018/12/1532f1414c3e23.jpg)

