You can imagine it as a simple object:
{ "-10" : 100, "-1" : 102, "3" : 44, "12" : -87, "12345" : 0 }
Since this will be a simple object, you cannot repeat it in the same way as an array, but you can use the for...in operator
for (var key in obj) { if (obj.hasOwnProperty(key)) { var value = obj[key]; } }
And if you want to access a specific element by key, you can also use the square bracket property accessor :
obj['-10'];
Note that I use the hasOwnProperty method inside for...in , this prevents iterative properties defined at higher levels of the prototype chain, which can cause problems and unexpected behavior ... more details here .
source share