创建二维数组的方法
一、对于小规模数据
var grades = [ [ 89, 77, 78 ], [ 76, 82, 81 ], [ 91, 94, 89 ] ]; alert(grades[2][2]); // 显示 89
二、对于大规模数据
Array.matrix = function(numrows, numcols, initial) { var arr = []; for ( var i = 0; i < numrows; ++i) { var columns = []; for ( var j = 0; j < numcols; ++j) { columns[j] = initial; } arr[i] = columns; } return arr; } var nums = Array.matrix(5, 5, 0); alert(nums[1][1]); // 显示 0