title: 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)?
body: <p>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.</p>
  <p>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?</p>
  <p>But I don't think arrays can store <em>BigInt</em> 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?</p>
  <p>Basically, how do maps, sparse arrays, and objects compare? When is which more optimized regarding my integer/bigint use case?</p>