for循环

5人阅读 评论(0) 收藏 举报
分类:
<!DOCTYPE html>
<html>
<head>
	<title>LIAOXIANLI</title>
	<script type="text/javascript">
		cars=["BMW","Volvo","Saab","Ford"];
		for (var i = cars.length - 1; i >= 0; i--) {
			document.write(cars[cars.length-i-1]+"<br>");
		}
	</script>
</head>
<body>

</body>
</html>
for后面的i从cars.length-1递减,小于0时退出循环
查看评论
    个人资料
    持之以恒
    等级:
    访问量: 725
    积分: 204
    排名: 91万+
    文章存档