数组的最大值的获取 <script> <BR>//定义数组 <BR>var arr = [1,4,3,9,5,0,-1,7,22]; <br><br>//最大值的下标,先假定为第一个元素的下标 <BR>var index = 0; <BR>for(var x = 0; x < arr.length; x++){ <br><br>if(arr[index] < arr[x]){ <BR>index = x; <BR>} <BR>} <br><br>document.write("索引为" + index + "中的" + arr[index] + "最大"); <br><br></script>