title: Remove an item from associative array in Javascript
body: <p>I have an Array of objects, example</p>
  
  <pre><code>Item[0] ="{ id1: 1}";
  Item[1] ="{ id2: 2}"; 
  Item[2] ="{ id3: 3}"; 
  </code></pre>
  
  <p>I have to delete an item by knowing an specific id. For example, if i get id2, i have to delete Item[1]. </p>
  
  <p>I tried to solve it, but it deletes the last item</p>
  
  <pre><code>for (var i = 0; i &lt; items.length; i++) {
              var _item = items[i];
              var funcId = getValueKey(_item);
  
          if(funcId == _item)
          {
              delete items[i];
          }      
          };
  </code></pre>
  
  <p>The getValueKey func</p>
  
  <pre><code>getValueKey: function(obj){
          for (var key in obj) {
              if (obj.hasOwnProperty(key)) {
                  return key;
  
              }
          }
  </code></pre>