for each key in dictionary javascript code example
Example 1: javascript foreach key value
myObject ={a:1,b:2,c:3}
Object.entries(myObject).forEach(([key, value]) => {
console.log(key , value);
});
Object.keys(myObject).forEach(key => {
console.log(key , myObject[key])
})
Example 2: foreach key value javascript
const object1 = {
a: 'somestring',
b: 42
};
for (let [key, value] of Object.entries(object1)) {
console.log(`${key}: ${value}`);
}
Example 3: js foreach key value
Object.keys(obj).forEach(function (key) {
});