方法一:

//方法一
const arr = [5, 3, 6, 2, 9, 0, -1, 3, -5, 7];
const max = Math.max.apply(null, arr); //9
const min = Math.min.apply(null, arr); //-5
console.log(max)
console.log(min)

方法二:

//方法二
//数组最小值
const min = function(arr) {
var min = arr[0];
var len = arr.length;
for (var i = 1; i < len; i++){
if (arr[i] < min){
min = arr[i];
}
}
return min;
}
console.log(min([5, 3, 6, 2, 9, 0, -1, 3, -5, 7])) //-5

//数组最大值
const max = function(arr) {
var max = arr[0];
var len = arr.length;
for (var i = 1; i < len; i++){
if (arr[i] > max){
max = arr[i];
}
}
return max;
}
console.log(max([5, 3, 6, 2, 9, 0, -1, 3, -5, 7])) //9
}