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.
 
 
 
 

18 lines
393 B

/**
* 计算数组的最大值
* @param arr 数组
* @return 最大值
*/
export default 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