mapping 2 dimensional array javascript square matrix szie code example
Example 1: js array two dimensional
// declaration of a two-dimensional array
// 5 is the number of rows and 4 is the number of columns.
const matrix = new Array(5).fill(0).map(() => new Array(4).fill(0));
console.log(matrix[0][0]); // 0
Example 2: creating 2d array in javascript
var [r, c] = [5, 5];
var m = Array(r).fill().map(()=>Array(c).fill(0));