2

I have a question for JS Map object's internal structure. In other languages(e. g. C++ std::map), Map has implemented by Red-Black tree or Hash containers. So, I want to know How JS implements Map.

HubCodes
  • 33
  • 1
  • 3
  • That depends on the JS engine – Luca Kiebel Aug 25 '18 at 13:48
  • 1
    Obviously depends on the engine but for V8 this might be helpful: https://codereview.chromium.org/220293002/. Edit: also, https://wiki.mozilla.org/User:Jorend/Deterministic_hash_tables – roryrjb Aug 25 '18 at 13:49
  • 1
    [ECMAScript 2015 Language Specification – ECMA-262 6th Edition -> 23.1 `Map` objects](https://www.ecma-international.org/ecma-262/6.0/#sec-map-objects): _"Map object must be implemented using either hash tables or other mechanisms that, on average, provide access times that are sublinear on the number of elements in the collection. The data structures used in this Map objects specification is only intended to describe the required observable semantics of Map objects. **It is not intended to be a viable implementation model**."_ – Andreas Aug 25 '18 at 13:49
  • https://stackoverflow.com/questions/33611509/es6-map-and-set-complexity-v8-implementation/33614512#comment55003664_33614512 – Bergi Aug 25 '18 at 17:07
  • Thank you for all answers. :) – HubCodes Aug 25 '18 at 23:54

0 Answers0