how to iterate a map in javascript code example
Example 1: iterate map
Map<String, String> map = ...
for (Map.Entry<String, String> entry : map.entrySet()) {
System.out.println(entry.getKey() + "/" + entry.getValue());
}
Example 2: loop through map in js
const object = {'a': 1, 'b': 2, 'c' : 3};
for (const [key, value] of Object.entries(object)) {
console.log(key, value);
}
Example 3: iterate over map key value javascript
recipeMap.forEach((value, key) => {
console.log(`${key} costs ${value}`);
});
Example 4: js loop trough map
for (let key of map) {
console.log(key);
}