<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>二维数组</title>
<script type="text/javascript">
var myarr =new Array();
for(var i=0;i<=2;i++){
var myarr[i]=new Array
for( var j=0;j<=5;j++){
myarr[i][j]=i*j;
document.write(myarr.[i][j]+</br>);
}
}
var myarr2 =[[0,0,0,0,0,0],[0,1,2,3,4,5],[0,2,4,6,10]];
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>二维数组</title> <script type="text/javascript"> var myarr =new Array(); for(var i=0;i<=2;i++){ myarr[i]= new Array(); for( var j=0;j<=5;j++){ myarr[i][j]=i*j; document.write(myarr[i][j]+"</br>"); } var myarr2 =[[0,0,0,0,0,0],[0,1,2,3,4,5],[0,2,4,6,10]]; }
改过后的代码
document.write(myarr.[i][j]+"</br>"); </br>加双引号;
var myarr[i]=new Array 改为 myarr[i]= new Array();