You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

21 lines
478 B

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = max;
/**
* 计算数组的最大值
* @param arr 数组
* @return 最大值
*/
function max(arr) {
if (!Array.isArray(arr))
return -Infinity;
var length = arr.length;
if (!length)
return -Infinity;
var max = arr[0];
for (var i = 1; i < length; i++) {
max = Math.max(max, arr[i]);
}
return max;
}
//# sourceMappingURL=max.js.map