Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

102
Views
Javascript array contents are defined as empty

i used a console.log for a 3d array and this is its contents

i used a console.log for a 3d array and this its contents

for the second its contents are clear

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

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

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)

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!