1var myObject = { 'a': 1, 'b': 2, 'c': 3 };
2
3Object.keys(myObject).map(function(key, index) {
4 myObject[key] *= 2;
5});
6
7console.log(myObject);
8// => { 'a': 2, 'b': 4, 'c': 6 }
1Object.entries(obj).forEach(([key, value]) => {
2 console.log(key, value);
3});
1for (const [key, value] of Object.entries(object1)) {
2 console.log(`${key}: ${value}`);
3}
4
1let map = new Map();
2map.set("a", 1);
3map.set("b", 2);
4map.set("c", 3);
5
6let obj = Array.from(map).reduce((obj, [key, value]) => (
7 Object.assign(obj, { [key]: value }) // Be careful! Maps can have non-String keys; object literals can't.
8), {});
9
10console.log(obj); // => { a: 1, b: 2, c: 3 }