How can I implement an array with an indexer in JavaScript? Is there something like a dictionary in .Net?
ECMAScript 6 (aka the 2015 JavaScript spec), specifies a dictionary interface, named Map. It supports arbitrary keys of any type, has a read-only size
property, is not cluttered with prototypes related stuff like objects, and can be iterated over using the new for...of...
construct or Map.forEach
. Check the documentation on the MDN here, and the browser compatibility table here.