arr.sort()方法的使用记录
var points = [40, 100, 1, 5, 25, 10]; points.sort(function(a, b) { return a - b; //升序 }); console.log(points); //[1, 5, 10, 25, 40, 100] points.sort(function(a, b) { return b - a; //降序 }); console.log(points); //[100, 40, 25, 10, 5, 1] console.log('数组的最大值:' + Math.max.apply(null, points));