Map Object
A JavaScript-specific data structure similar to an Object but remembers insertion order and is iterable. It also has far better performance when inserting and deleting keys-value pairs.
More info: Map - JavaScript | MDN
Increment & Decrement
let mapObj = new Map();
const incrementMapVal = (map, key) => {
const currentValue = map.has(key) ? map.get(key) : 0;
map.set(key, currentValue + 1);
}
const decrementMapVal = (map, key) => {
const currentValue = map.has(key) && map.get(key);
currentValue > 1 ? map.set(key, currentValue - 1) : map.delete(key);
}