1for (var [key, value] of phoneBookMap) {
2 console.log(key + "'s phone number is: " + value);
3}
4
1const object = {a: 1, b: 2, c: 3};
2
3for (const property in object) {
4 console.log(`${property}: ${object[property]}`);
5}
1const obj = {
2 a: "aa",
3 b: "bb",
4 c: "cc",
5};
6//This for loop will loop through all keys in the object.
7// You can get the value by calling the key on the object with "[]"
8for(let key in obj) {
9 console.log(key);
10 console.log(obj[key]);
11}
12
13//This will return the following:
14// a
15// aa
16// b
17// bb
18// c
19// cc
1for (let key in yourobject) {
2 if (yourobject.hasOwnProperty(key)) {
3 console.log(key, yourobject[key]);
4 }
5}
6