title: Issue when checking if key exist in array and setting a new value with variables
body: <p>I'm trying to check if key exists in array and change it if it does, or add if does not. I need to do it without jQuery.
  I store the array in cookies stringified.</p>
  
  <pre><code>if (item_id in items) items[item_id] = count;
  else
  {
      var tmp = {};
      tmp[item_id] = count;
      items.push(tmp);
  }
  </code></pre>
  
  <p><code>item_id</code> and <code>count</code> are always numbers. The problem is when I check if key exists it checks the number of element in array. For example, if I have pair <code>[{1:5},{5,3}]</code> and check if key 5 exists if returns false, if I check for key 1 it returns true and changes the array like that <code>[{1:5},new_value]</code></p>
  
  <p>I tried <code>if (item_id in items)</code>, <code>if (items[item_id])</code>, didn't work. How should I make it work correctly?</p>