獲取 Map 的元素數量

要獲取 Map 的元素數量,請使用 .size 屬性:

const map = new Map([[1, 2], [3, 4]]);
console.log(map.size); // 2