I'm curious about the internals of v8 and how Map
is implemented under the hood. Contrasting Map
s, javascript objects cannot have objects as keys. As far as I understand it Map
s implement lookup in the classic hash map fashion. Some hashing function maps the input key to some output integer, which is used as an index in an array. Then there's some dynamic resizing when the array overflows and some linkedlist in each bin of the array. Probably the details of v8's maps are a little more intricate and they involve some optimizations for small Map
s? Curious to know how much the actual implementation differs from my above sketch. Based on the assumption that Map
works like this under the hood, how does it map from a plain object to a key in the array? I am guessing it modulos the pointer address into the array?
Curious to dig deeper.