javascript中数组中求最大值示例代码

时间:2013-12-18    点击:94   
复制代码 代码如下:

<html>
<head>
<title>数组的最大值的获取</title>

<script>
//定义数组
var arr = [1,4,3,9,5,0,-1,7,22];

//最大值的下标,先假定为第一个元素的下标
var index = 0;
for(var x = 0; x < arr.length; x++){

if(arr[index] < arr[x]){
index = x;
}
}

document.write("索引为" + index + "中的" + arr[index] + "最大");

</script>

</head>

<body>
<div id="time"></div>
</body>

</html>
Javascript改变CSS样式(局部和全局)
jquery 提示信息显示后自动消失的具体实现
javascript中数组的concat()方法使用介绍
javascript中数组的sort()方法的使用介绍
javascript中数组的冒泡排序使用示例
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved