var a=[1,2,3,5]; alert(Math.max.apply(null, a));//最大值 alert(Math.min.apply(null, a));//最小值
多维数组可以这么修改:
var a=[1,2,3,[5,6],[1,4,8]]; var ta=a.join(",").split(",");//转化为一维数组 alert(Math.max.apply(null,ta));//最大值 alert(Math.min.apply(null,ta));//最小值
Powered by: 博客园 Copyright © 2024 _eve Powered by .NET 9.0 on Kubernetes