title: Why does the splice method have this strange behavior?
body: <p>In my application I need to delete an element from an array. However I am new to JS. I searched the web and every blog post was talking about splice() method. So I considered to used it, but it has a very strange behavior.</p>
  
  <p>Here the post I found : 
  <a href="http://www.w3schools.com/jsref/jsref_splice.asp" rel="nofollow">http://www.w3schools.com/jsref/jsref_splice.asp</a>
  http://viralpatel.net/blogs/javascript-array-remove-element-js-array-delete-element/</p>
  
  <p>Here is my Test:</p>
  
  <pre><code>it("should delete all elements in array", function () {
      var ary = new Array();
  
      for (i = 0; i &lt; 10; i++) {
          ary[i] = Math.random();
      }
  
      expect(ary.length).toBe(10);
  
      for (i = 0; i &lt; 10; i++) {
          ary.splice(i, 1);
      }
  
      expect(ary.length).toBe(0);
  
  });
  </code></pre>
  
  <p>And here is the result of the test:  </p>
  
  <pre><code>  Firefox 15.0.1 Linux: Run 7 tests (Passed: 6; Fails: 1; Errors 0) (44.00 ms)
      should delete all elements in array failed (5.00 ms): Error: Expected 5 to be 0.
  </code></pre>
  
  <p>I use angular JS.</p>
  
  <p>Thanks very much for replies. Here is another test that just don't pass: </p>
  
  <pre><code>var ary = new Array();
  
          ary = ['a', 'b', 'c', 'd'];
  
          ary.splice(0, 1);
  
          ary.splice(1, 1);
  
          ary.splice(2, 1);
  
          ary.splice(3, 1);
  
          expect(ary.length).toBe(0);
  
  Firefox 15.0.1 Linux: Run 7 tests (Passed: 6; Fails: 1; Errors 0) (49.00 ms)
      Posting server policy.should delete all elements in array failed (5.00 ms): Error: Expected 2 to be 0.
  </code></pre>
  
  <p>as @Matteo Tassinari suggest this should one should delete all elements right ??  </p>