what is a map?
The map is a collection of elements where each element is stored as a Key, or value pair.
How To get map length
In Javascript, we can easily get the length of a map using the size property. The map size property is read only and returns an integer value.
For Example:
const map = new Map();
map.set('foo', 1);
map.set('bar', 2);
map.set('baz', 3);
Now Get the map length using the size property
console.log(map.size); //3
The size property is read-only and can’t be changed. Let’s take one more example
const map = new Map();
map.set('foo', 1);
map.set('bar', 2);
console.log(map.size); // 2
map.size = 7;
console.log(map.size); // 2
Here we tried to change the map size but we were unable to.