i used a console.log for a 3d array and this is its contents
for the second its contents are clear
for(let mmm = 0; mmm < NumOfPatterns;mmm++)
{
for(let i = 0; i < 36; i++)
{
for(let j = 0; j < 36; j++)
{
patterns[mmm][i][j] = 0;
console.log(patterns[mmm][i][j]);
}
}
}
I use this function just to define every value to 0
I think you should check if the arrays exist:
const NumOfPatterns = 10
const DEFAULT_ARR_LENGTH = 36
let arr3d = []
// checking if the referenced elements exist
// if not, create them on the first iteration
for (let mmm = 0; mmm < NumOfPatterns; mmm++) {
if (typeof arr3d[mmm] === "undefined") arr3d[mmm] = []
for (let i = 0; i < DEFAULT_ARR_LENGTH; i++) {
if (typeof arr3d[mmm][i] === "undefined") arr3d[mmm][i] = []
for (let j = 0; j < DEFAULT_ARR_LENGTH; j++) {
arr3d[mmm][i].push(0)
}
}
}
console.log(arr3d)