title: Delete from array in javascript
body: <p>3 hours ago, I asked a question in SO , about deleting a part of an object, so I linked this question to it:</p>
  
  <p><a href="https://stackoverflow.com/questions/9359774/how-to-remove-a-part-of-an-object-in-javascript">delete a part of object in javascript</a></p>
  
  <p>but now another problem occurred when I deleted from that array.
  I use that object to populate a FlexiGrid. but when I delete an item from that object by following code, instead of delete that item , it sets to undefined :( and flexigrid did not accept it for input data.</p>
  
  <pre><code>for (var i = 0; i &lt; Roomdata.length; i++) {
  
      if(Roomdata[i].id = X) {
  
          delete Roomdata[i];
          break;
  
      }
  }                
  </code></pre>
  
  <p>For example, imagine I have 3 items in Roomdata like this : </p>
  
  <pre><code>{item1, item2, item3}
  </code></pre>
  
  <p>When I call this code to delete item2 , Roomdata object looks like this : </p>
  
  <pre><code>{item1, undefined, item3}
  </code></pre>
  
  <p>and this is a bad format to be accepted by flexigrid as input data</p>
  
  <p>Is there any solution ?</p>
  
  <p>Thanks every body and sorry about my bad syntax (I am new in English)</p>
  
  <p>regards , Foroughi</p>