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

226
Views
Eficiencia de `num[i] = i` vs `num.push(i)` en JavaScript

Tenía curiosidad (y no tenía nada que hacer) y decidí ejecutar un punto de referencia con lo siguiente para agregar elementos a las matrices:

 var num = []; for (var i = 0; i < 1000; i++) { num.push(i); }

parece ser un 90% más lento que

 var num = []; for (var i = 0; i < 1000; i++) { num[i] = i; }

Las posiciones de los elementos no me importan en este caso (siempre que se agreguen a la matriz).
¿Alguien puede explicar por qué Array.prototype.push() es mucho más lento? Puede encontrar el punto de referencia aquí .

about 4 years ago · Juan Pablo Isaza
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!