title: JavaScript object properties count limit, deleting oldest updated ones
body: <p>I would like to implement a size limit for JavaScript objects and their properties count. What I need is to delete oldest updated one when a new property is added to an object.</p>
  
  <p>Consider the following object, where I count the number of occurrences of each letter (but only for the 2 latest letters seen) in a text:</p>
  
  <p><code>
  var occurrences = {a: 1, d: 2}
  </code></p>
  
  <p>When I read <code>a</code> I'll increment <code>occurrences['a']</code> by one. But after that, if I see <code>h</code> I have to delete <code>d</code>, because it was less recently updated than <code>a</code>. Then, my object would be the following:</p>
  
  <p><code>
  {a: 2, h: 1}
  </code></p>
  
  <p>There are good reasons to use an object for this purposes, so I cannot use a sorted array, for instance, because performance is very very important.</p>