<!DOCTYPE html> <html> <body> <h1>JavaScript Map 对象</h1> <p>使用 Map.forEach():</p> <p id="demo"></p> <script> // 创建 Map const fruits = new Map([ ["apples", 500], ["bananas", 300], ["oranges", 200] ]); let text = ""; fruits.forEach (function(value, key) { text += key + ' = ' + value + "<br>" }) document.getElementById("demo").innerHTML = text; </script> </body> </html>