运行 ❯
获取您
的
网站
×
更改方向
保存代码
更改主题,暗色/亮色
前往 Spaces
<!DOCTYPE html> <html> <body> <h1>JavaScript Maps</h1> <h2>The new Map() Method</h2> <p>Creating a map from an array:</p> <p id="demo"></p> <script> // Create a Map const fruits = new Map([ ["apples", 500], ["bananas", 300], ["oranges", 200] ]); let x = fruits.get("apples"); document.getElementById("demo").innerHTML = "The number of apples in fruits are " + x; </script> </body> </html>