W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <h1>JavaScript 对象方法</h1> <p>Object.entries() 使将对象转换为 Map 变得简单:</p> <p id="demo"></p> <script> const fruits = {Bananas:300, Oranges:200, Apples:500}; const myMap = new Map(Object.entries(fruits)); document.getElementById("demo").innerHTML = myMap; </script> </body> </html>