Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 我在尝试创建数字字符串值的2D数组时出错_Javascript_Arrays_String_2d_Tostring - Fatal编程技术网

Javascript 我在尝试创建数字字符串值的2D数组时出错

Javascript 我在尝试创建数字字符串值的2D数组时出错,javascript,arrays,string,2d,tostring,Javascript,Arrays,String,2d,Tostring,当我运行console.log时,我得到了所有正确的返回值,但是chrome说将location初始化为var location=[]时出错;我和我的同学都不明白为什么 var location = []; /*This set of loops should create a 2D array called location and assign a string value to match it's position in the 2D array so that

当我运行console.log时,我得到了所有正确的返回值,但是chrome说将location初始化为var location=[]时出错;我和我的同学都不明白为什么

var location = [];
    
    /*This set of loops should create a 2D array called location and assign
    a string value to match it's position in the 2D array so that
    location[0][0] == "00" and location[2][1] == "21".
    */
    for(var i = 0; i < row; i++) {
      
      location[i] = [];
      
      for(var j = 0; j < col; j++) {
        
        location[i][j] = i.toString() + j.toString();
        console.log("i" + i +"\tj"+ j + " "+ location[i][j]);
      }
      
    }
var位置=[];
/*这组循环应该创建一个名为location和assign的二维数组
匹配其在二维数组中位置的字符串值,以便
位置[0][0]=“00”和位置[2][1]=“21”。
*/
对于(变量i=0;i
“位置”是
窗口的只读属性。把你的代码放在一个函数中,它就会工作。编辑不是真正的“只读”,但其类型是固定的;它是位置对象(URL、查询字符串等)。