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

217
Views
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
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!