I would like to create an empty 2D array. I know the size of the array, this gets dynamically decided. After the creation I want to insert different DOM objects inside this 2D array on dynamically created arraylocations. It says cannot set property of undefined. Did I do something wrong with the array initialisation?
let gridArrayNumbers = [];
section.Layout.forEach(layout => {
gridArrayNumbers.push(layout);//finallyhis , tarray will contain {2,3}
});
let gridArray: any [][] = [];
...
let e = document.createElement("label");
e.textContent = element.content;
gridArray[element.layout.row][element.layout.column] = e;//throws the error here of undefined
gridArrayis an empty array, sogridArray[element.layout.row][element.layout.column]isn't going to workcore.js:1350 ERROR Error: Uncaught (in promise): TypeError: Cannot set property '0' of undefined, the 0 property is a value that I know. @VikhyathMaiya