How to check if a Map or Set is empty?

You can do this directly

if(storeMapDetails.size == 0){
    //Do something
}

You can check this directly


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.)