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

236
Views
iterar para cada elemento de la variable, obtuve TypeError

Me gustaría hacer algo para cada elemento en my_var :

 // get selected rows of DataTable let table_data = dtMember.rows({ selected: true }).data(); const COL_INDEX = 4 ; // column index of the column to count let my_var = table_data.reduce(function (col_to_count, currentValue) { if (currentValue[COL_INDEX] in kulturen) { col_to_count[currentValue[COL_INDEX]]++; } else { col_to_count[currentValue[COL_INDEX]] = 1; } return col_to_count; }, {});

Lo intenté:

 for (const element of my_var) { console.log(element); }

pero conseguir el

TypeError: my_var no es eterable

Probé también my_var.entries() y my_var.keys() , que se sugieren en la página de ayuda de Firefox, pero let to is not a function

¿Cómo puedo hacerlo correctamente?

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

0

Usar in para Objetos. of es para iterar sobre Arrays.

 for (const key in my_var) { console.log(key, my_var[key]) }
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!