「JavaScript入門」for(){}とfor inで配列の要素を取得するコード

1.for(){}方法
<script type="text/javascript">
<!–
var arr = new Array(88.15,3,24,5,6);
for(var i=0;i<arr.length;i++){
arr[i] = arr[i]/2.0;
}
alert(arr);
//–>
</script>

2.for in方法
<script type="text/javascript">
var x;
var pacars = new Array();
pacars[0] = “Bensen";
pacars[1] = “Toyoda";
pacars[2] = “Mazida";
for (x in pacars)
{
document.write(pacars[x] + “<br />");
}
</script>

JavaScript

Posted by arkgame