itera sobre o valor do mapa JavaScript
recipeMap.forEach((value, key) => {
console.log(`${key} costs ${value}`);
});
skjaved
recipeMap.forEach((value, key) => {
console.log(`${key} costs ${value}`);
});
const object = {'a': 1, 'b': 2, 'c' : 3};
for (const [key, value] of Object.entries(object)) {
console.log(key, value);
}
map = new Map();
map.set('key1', 'value1');
map.set('key2', 'value2');
for (let [key, value] of map.entries()) {
console.log(key + ' - ' + value)
}
let map = new Map();
map.set('key1', 'value1');
map.set('key2', 'value2');
for (let [key, value] of map.entries()) {
console.log(key + ' - ' + value)
}
for (let key of map) {
console.log(key);
}
Object.keys(obj).forEach(function (key) {
// do something with obj[key]
});