const a = { one: 1, two: 2, three: 3}; let key, val; for (key in a) { val = a[key]; document.writeln('a[' + key + ']=' + val + '<br>'); }
Programming Tips - javaScript: enumerate all items in a javaScript associative array
Date: 2009jun29
Language: javaScript
Level: beginner
Q. javaScript: enumerate all items in a javaScript associative array
Is there a foreach like some other languages?
A. There is no foreach, this is how you do it in javaScript: