@DasSurma (wonder if you might wanna help answer this question) Why did TC39 decide to not give new Map() indexes? https://stackoverflow.com/questions/37822141/how-do-you-get-the-key-at-specifc-index-in-javascript-map-object … Right now we have to loop through the Map to get the index of a key.
Maps (and sets) are indeed unordered. If the order matters, use an array instead.
-
-
I believe ES sets and maps are ordered in insertion order. It's not explicitly specified, but the specification device uses a List which implies an ordering.
-
If ordering matters, then maps or sets are conceptually the wrong data structure. My mental model is that maps contain a pile of key/value pairs, and sets contain a pile of values. This is also why maps/sets get a `size` rather than a `length`. Length implies an inherent order.
- 5 more replies
New conversation -
-
-
Or use an object (they're ordered since ES2015
). -
Now that Objects are ordered, I'm thinking abt how it'll play well across d industry since d JSON standard defines Objects as "an unordered set of name/value pairs" http://json.org/ Might anyone frm ECMA-404 want to weigh in?
@timbray@bterlson@secoif@bakkoting@domenic - 3 more replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
JavaScript, HTML, CSS, HTTP, performance, security, Bash, Unicode, i18n, macOS.