Run ❯
Get your
own
website
Result Size:
625 x 565
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <body> <h1>JavaScript Maps</h1> <p id="demo"></p> <script> // Create Objects const apples = {name: 'Apples'}; const bananas = {name: 'Bananas'}; const oranges = {name: 'Oranges'}; // Create a Map const fruits = new Map(); // Add Elements to the Map fruits.set(apples, 500); fruits.set(bananas, 300); fruits.set(oranges, 200); document.getElementById("demo").innerHTML = fruits.get("apples"); </script> </body> </html>