<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script>
var arr=[34,71,8,934,10];
var value=999;
var index=-1;
for(var i=0;i<arr.length;i++)
{
if(arr[i]<value)
{
value=arr[i];
index=i;
}
}
alert("最小值"+value+", 位置 :"+index)
</script>
</body>
</html>
时间: 2024-09-28 13:36:47