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

90
Views
¿Cómo se limitan los bucles for-in en Javasript?

¿Cómo puedo limitar for-in a 5 bucles incluso si hay más propiedades en el objeto?

 for(property in object){ //do this stuff for the first 5 properties }
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Sin contadores:

 Object.keys(object).slice(0,4).map((property) => { // do something with property })
about 4 years ago · Juan Pablo Isaza Report

0

Podrías usar un contador. Algo como esto:

 let counter = 0; for(property in object) { if (counter >= 5){ break; } counter++; }
about 4 years ago · Juan Pablo Isaza Report

0

Puedes usar un break;

Como esto

 let props = 0; for(property in object){ //do this stuff for the first 5 properties props++; if (props > 4) break; }
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!