From MDN, javascript provides Map which is C++ equivalent to std::map. Is there a similar equivalent to unordered_map (providing O(1) insertions/lookup/deletion on avg).
Edit: As the answers suggest, std::unordered_map is more closer to javascript Map than std::map.
The equivalent of a JavaScript Map is the C++ unordered_map, as it provides sub-linear access (i.e. possibly logarithmic but constant in practice) and does not sort its keys. It keeps insertion order of elements for deterministic execution and cross-implementation compatibility, but it is not sorted.
There is no equivalent of the C++ map, which is implemented as a tree with comparable keys, in JavaScript.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With