Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

220
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda