title: Modify original array with Javascript Array.Filter
body: <p>I want to use Javascript's array.filter to remove items from an array, because the syntax is elegant and readable. However, it seems that filter doesn't modify the original array, it just returns a new array, filtered as you requested. My question is, why doesn't the following work as I expect?</p>
  
  <pre><code>$scope.clearList = function () {
    this.list = this.list.filter(function (item) {
      return item.checked == true;
    });
  
    //...
  }
  </code></pre>
  
  <p>I would expect that after returning the newly filtered array, this.list would now hold just the filtered set. It does not work like this however. this.list ends up containing exactly the same items. Altering the code to save out the filtered array in an intermediate variable shows that it is indeed filtering correctly. </p>
  
  <p>I've done a workaround for now, looping through the filtered version and splicing items out of the original list that should be filtered, but this is inelegant. Am I just thinking about it the wrong way?</p>
  
  <hr>
  
  <p>Sidenote: I'm using Angular.js. I'm unsure it matters at all, but the list comes from the following:</p>
  
  <pre><code>  &lt;div class="list" ng-repeat="list in lists"&gt;
      &lt;!-- ... --&gt;
      &lt;ul&gt;
        &lt;li ng-repeat="item in list"&gt;
          &lt;div&gt;
            &lt;label&gt;
              &lt;input type="checkbox" ng-model="item.checked"/&gt;
              {{item.name}}
            &lt;/label&gt;
            &lt;!-- ... --&gt;
          &lt;/div&gt;
        &lt;/li&gt;
      &lt;/ul&gt;
      &lt;button class="btn clear-selected" ng-click="clearList()"&gt;
        Remove Selected
      &lt;/button&gt;
    &lt;/div&gt;
  </code></pre>
  
  <hr>
  
  <p>Edit to add debugging info: I've introduced a temp variable just to see whats going on in the debugger.</p>
  
  <pre><code>var temp = this.list.filter(function (item) {
    return item.checked == true;
  });
  
  this.list = temp;
  </code></pre>
  
  <p>Before execution, this.List has 5 items, temp is undefined.
  After the first line is executed, this.List has 5 items, and temp has 2 items. 
  After the last line is executed, this.List has 2 items, temp has 2 items.</p>
  
  <p>However, it seems after this that the UI which is bound to this.list does not update. So something unrelated to filter does seem to be going on.</p>