<html>
<body>
<h1>JavaScript Map 对象</h1>
<h2>forEach() 方法</h2>
<p id="demo"></p>
<script>
// 创建一个 Map
const fruits = new Map([
["apples", 500],
["bananas", 300],
["oranges", 200]
]);
let text = "";
// 使用 forEach 遍历 Map
fruits.forEach (function(value, key) {
text += key + ' = ' + value + "<br>"
})
// 显示结果
document.getElementById("demo").innerHTML = text;
</script>
</body>
</html>