I was looking to create a dynamic 3D array, here's the basic code I used:
const arr = new Array;
arr[0] = new Array;
arr[0][0] = new Array;
arr[0][0][0] = 'value1';
arr[1][0][0] = 'value2';
But I noticed that any value greater than 0 for the first 2 indexes throws
Uncaught TypeError: Cannot read property '0' of undefined
(0 is the value of the index following the previous which was greater than 0)
Is there a way to prevent this from happening without adding new arrays every time a new value is added?