-1

Any idea how to iterate a hash map object in JavaScript?

I tried the code below but it is not working.

for(var key : hmap)
{Alert(key + hmap[keep]);}
Pang
  • 9,564
  • 146
  • 81
  • 122
Magesh
  • 7
  • 1
  • Possible duplicate of [Looping through a 'Hashmap' in JavaScript](http://stackoverflow.com/questions/6748781/looping-through-a-hashmap-in-javascript) – Hambone Feb 18 '16 at 02:09
  • It is not working because `keep` is not defined? – Pang Feb 18 '16 at 02:27
  • *"I tried the code below"* - I guess using syntax from another language was worth a try, but when it didn't work did you not think to read some javascript tutorials/documentation? – nnnnnn Feb 18 '16 at 02:33
  • __JavaScript is not Java__. There is no _hashmap_, and if you actually checked your errors you would see `Uncaught SyntaxError: Unexpected token :`. – Oka Feb 18 '16 at 02:33

1 Answers1

0
for (var key in hmap) {
   alert(key + ':' + hmap[key])
}
Keith
  • 984
  • 6
  • 9