1.假設(shè)法
var arr = [1231,252,234];
var max = arr[0],min = arr[0];
for(var i=0;i<arr.length;i++) {
max < arr[i] ?max= arr[i]: null;
min > arr[i] ?min= arr[i]: null;
}
console.log(min,max);
2.sort法
var arr= [443,44334,12];
arr.sort(function (a,b) {
return a - b;
})
var min = arr[0],max = arr[arr.length - 1];
console.log(min,max);
3.Math.min + eval()
var arr = [4343,44,42242424];
var minstr = "Math.min("+arr.toString()+")";
var min = eval(minstr);
console.log(min);
4.apply + Math.min
var arr = [4343,44,42242424];
var min = Math.min.apply(null,arr);
console.log(min);