title: How to increment a value in a JavaScript object?
body: <pre><code>var map = {};
  map[key] = value;
  </code></pre>
  
  <p>How can I</p>
  
  <ul>
  <li>assign value 1 if key does not yet exist in the object</li>
  <li>increment the value by 1 if it exists</li>
  </ul>
  
  <p>Could I do better than:</p>
  
  <pre><code>if (map[key] == null) map[key] = 0;
  map[key] = map[key]++;
  </code></pre>