You use its size
property. Both Maps and Sets have it (here and here).
const populatedSet = new Set(['foo']);
console.log(populatedSet.size); // 1
const populatedMap = new Map([['foo', 1]]);
console.log(populatedMap.size); // 1
(Side note: WeakMaps and WeakSets don’t have size
or several other features their “strong” counterparts have, in order to keep their implementations, and code using them, sane. 🙂 Where they have similar functionality, they offer the same API, but they aren’t subclasses.)