1Object.entries(obj).forEach(
2 ([key, value]) => console.log(key, value)
3);
1// Looping through arrays created from Object.keys
2const keys = Object.keys(fruits)
3for (const key of keys) {
4 console.log(key)
5}
6
7// Results:
8// apple
9// orange
10// pear
11
1const fruits = {
2 apple: 28,
3 orange: 17,
4 pear: 54,
5}
6
7const values = Object.values(fruits)
8console.log(values) // [28, 17, 54]
9