What’s the best way to store a key=>value array in javascript, and how can that be looped through?
The key of each element should be a tag, such as {id} or just id and the value should be the numerical value of the id.
It should either be the element of an existing javascript class, or be a global variable which could easily be referenced through the class.
jQuery can be used.
That’s just what a JavaScript object is:
You can loop through it using
for..inloop:See also: Working with objects (MDN).
In ECMAScript6 there is also
Map(see the browser compatibility table there):