x
 
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Map.get() 方法</h1>
<p>Map.get() 返回 Map 中的指定元素,如果key不存在,则返回 undefined</p>
<p id="demo"></p>
<script>
// 创建对象
const apples = {name: 'Apples'};
const bananas = {name: 'Bananas'};
const oranges = {name: 'Oranges'};
// 创建新的 Map
const fruits = new Map();
// Add new Elements to the Map
fruits.set(apples, 500);
fruits.set(bananas, 300);
fruits.set(oranges, 200);
//
// 返回 500
document.getElementById("demo").innerHTML = "水果中苹果的数量是:" + fruits.get("apples");
</script>
</body>
</html>