x
 
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript 映射</h1>
<p id="demo"></p>
<script>
// 创建对象
const apples = {name: 'Apples'};
const bananas = {name: 'Bananas'};
const oranges = {name: 'Oranges'};
// 创建一个映射
const fruits = new Map();
// 向映射中添加元素
fruits.set(apples, 500);
fruits.set(bananas, 300);
fruits.set(oranges, 200);
document.getElementById("demo").innerHTML = fruits.get("apples");
</script>
</body>
</html>