2

If I use object literal as a map, I can simply do: obj[key]++, but for a map created through new Map, right now I had to do the follows:

let currentVal = myMap.get(key);
myMap.set(currentVal + 1);

Which is a lot of typing and no where near elegant. I read up on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map but there doesn't seem to be an example that covers my use case.

benjaminz
  • 3,118
  • 3
  • 35
  • 47

0 Answers0