<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>求数组中的最值</title>
</head>
<body>
<center>
<button onclick="strParse()">普通字符串</button>
<div id="display" align="center"></div>
</center>
<script type="text/javascript">
Array.max = function(array){
return Math.max.apply(Math,array);
}
Array.min = function(array){
return Math.min.apply(Math,array);
}
var arr = [1,2,3,4,5];
var max = Array.max(arr);
var min = Array.min(arr);
document.write("最大值:"+max);
document.write("<br />");
document.write("最小值:"+min);
</script>
</body>
</html>
时间: 2024-10-06 16:36:17