typescript instantiate 2d array 1

typescript instantiate 2d array

let myArray: boolean[][] = Array(10).fill([]).map(() => Array(10).fill(false));

Here is what the above code is Doing:
1. Create an array of 10 empty arrays.
2. Fill each of those 10 arrays with 10 false values.
3. Return the array of arrays.

Similar Posts