Is there an opportunity to declare in JavaScript two-dimensional arrays except option:
mass = [[1,2,3], [4,5,6], [7,8, nine]]
i.e. If the dimension of the array is transmitted to the function, and the function generates an array with the specified dimension?
Answer 1, Authority 100%
Of course.
Function Matrixarray (Rows, Columns) {
var arr = new array ();
For (var i = 0; i & lt; rows; i ++) {
arr [i] = new array ();
For (var j = 0; j & lt; columns; j ++) {
Arr [i] [j] = i + j + 1; // instead of i + j + 1 we write any filler. In the simplest case - NULL
}
}
RETURN ARR;
}
var MyMatrix = Matrixarray (3.3);