Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

221
Vistas
How are maps and sparse arrays implemented under the hood for JavaScript in v8 (to determine which would be more optimized for a specific use case)?

I am having to figure out the best way to store objects when using an integer or BigInteger as a key. This leaves me with 3 choices for what I care about: objects, maps, or sparse arrays.

I think I know that objects in v8/JavaScript are implemented as hash tables using quadratic probing. So there is that to consider. I briefly read that v8 optimizes for sparse arrays (so say I insert 1 million items by incrementing an integer key, then I delete 900k of them throughout). Wondering if sparse arrays would be an optimization in this case over objects, storing an integer key. How are sparse arrays implemented under the hood in v8, so I can determine if it would contain optimizations?

But I don't think arrays can store BigInt keys, so that would leave me with objects vs. maps. The second part of the question is how maps are implemented under the hood in v8. If I stored an integer key in a sparse array vs. a map, what would be the tradeoffs? If I stored a BigInt key in an object vs. a map, what would be the tradeoff? Object keys would serialize the BigInt into a string, then use the quadratic probing algorithm to insert/find/delete it. But what would maps do?

Basically, how do maps, sparse arrays, and objects compare? When is which more optimized regarding my integer/bigint use case?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda