loop on associative array js code example
Example 1: loop dictionary with key and value javascript
const object = {'a': 1, 'b': 2, 'c' : 3};
for (const [key, value] of Object.entries(object)) {
console.log(key, value);
}
Example 2: js loop through associative array
var months = [];
months["jan"] = "January";
months["feb"] = "February";
months["mar"] = "march";
for (var key in months) {
var value = months[key];
console.log(key, value);
}