JavaScript数组与Java数组的比较
源代码如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script>
// int[] arry = new int[5];
//方法一、
var arry = new Array(5);
// int[] arry = {1,2,3,4,5};
//方法二、
var arry2 = [1,3.14,"hello",true];
// int[] arry = new int[]{1,2,3,4};
//方法三、
var arry3 = new Array(1,3.14,"hello",true);
// alert(arry2.length);
//遍历
for (var i = 0; i<arry2.length; i++) {
document.write(arry2[i]+"<br>");
}
</script>
</head>
<body>
</body>
</html>
网页输出效果如下: