Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

11
  • 1. Arrays and hashmaps are entirely different data structures, even in JavaScript. One is not a subset of the other. 2. Looping over an array with a for..in loop is asking for subtle bugs and has been considered bad practice for at least the last 6 years. Commented Dec 21, 2017 at 16:43
  • stackoverflow.com/questions/684672/… Commented Dec 21, 2017 at 16:46
  • @JaredSmith I'm well aware that they are different data structures, but in general arrays are implementation in JS as special versions of hashmaps. For a couple of examples See the Mozilla Rhino implementation of an array at: [github.com/mozilla/rhino/blob/master/src/org/mozilla/javascript/…. The comment on line 2121 describes the overall strategy, where dense arrays use an actual underlying array, but anything else uses HashTable storage. Spider Monkey at: [hg.mozilla.org/mozilla-central/file/tip/js/src/vm/… takes a similar approach. Commented Apr 19, 2018 at 13:51
  • @user602607 implementation details !== semantics. Or performance. Or aid in correctness. Commented Apr 19, 2018 at 13:55
  • 1
    @JaredSmith in all due respect, while I was clearly wrong, and am indeed reflecting on how to create proper answers... I also feel that conversation is healthy, and the only way to properly resolve misunderstandings. I would also bring up these points in a work environment. Thank you for your time, I will stop now. Commented Apr 19, 2018 at 14:15