// 创建二维数组 Array.matrix = function (rows, cols, initial) { var arr = []; for (var i = 0; i < rows; i++) { var column = []; for (var j = 0; j < cols; j++) { column[j] = initial; } arr.push(column); } return arr; };