JavaScript循环语句
- for循环、for/in
- while循环、do…while
for循环
<script> var i=[1,2,3,4,5,6]; for(var j= 0;j<6;j++){ document.write(i[j]+"、"); } </script>
也可以把var j=0和j++拿出来
<script> var i=[1,2,3,4,5,6]; var j= 0; for(;j<6;){ document.write(i[j]+"、"); j++; } </script>
for/in
<script> var i=[1,2,3,4,5,6]; var j; for(j in i){ document.write(i[j]+"<br/>"); } </script>