问答详情
源自:3-7 二维数组

为什么无法输出呢?

<!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>


提问者:karawoo 2015-10-31 16:46

个回答

  • 逆光之羽
    2015-10-31 17:12:48

    <!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();