代码示例:(标识:js_map_set_new)
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Map 对象</h1>
<p>使用 Map.set():</p>

<p id="demo"></p>

<script>
// 创建 Map
const fruits = new Map();

// 设置 Map 的值
fruits.set("apples", 500);
fruits.set("bananas", 300);
fruits.set("oranges", 200);

document.getElementById("demo").innerHTML = fruits.get("apples");
</script>

</body>
</html>
运行结果: