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

130
Views
Is there a better way, to iterate through

How to iterate in a better way through A and B?

Data structure A:

AbsatzNrSaetzeText: { [key: string]: string[] };

Data structure B:

 AbsatzNrSaetzeText: Record<number, string[]>;

Is there a better way, to get that value:

     for (var i = 0; i < this.UI_Seiten.length; i++) {
      for (var j in this.UI_Seiten[i].AbsatzNrSaetzeText) {
        for (var k = 0; k < this.UI_Seiten[i].AbsatzNrSaetzeText[j.valueOf()].length; k++) {
          console.log(this.UI_Seiten[i].AbsatzNrSaetzeText[j.valueOf()][k]);
        }
      }
    }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

For iterable objects (like arrays), there is no need to reference the index in order to iterate over the values - for..of allows for significantly cleaner code, by putting the value being iterated over directly into an identifier that can be used in later loops.

Use Object.values instead of for..in, since you don't care about the key on the object, only about the value.

for (const seiten of this.UI_Seiten) {
    for (const arr of Object.values(seiten.AbsatzNrSaetzeText)) {
        for (const str of arr) {
            console.log(str);
        }
    }
}
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!