title: Typescript array.splice() function weird behavior
body: <p>Hello dear Stackoverflow Community</p>
  <p>I have encouraged some strange behavior when using splice on my array. I splice the array &quot;tempFilterdProduts&quot; but also the array &quot;this.products&quot; seems to be affected. As a console.log shows the array &quot;this.products&quot; is getting shorter. Is there anything I'm missing here? Any help would be much appreciated!
  I'm using Angular 12</p>
  <pre><code>let tempFilterdProduts = this.products
  let itemsToDelete: number[] = [];
  let tempCategoryFilterList: number[] = []
  this.allCategoriesCheckBox.forEach(ategoriesCheckBox =&gt; {
    if (!ategoriesCheckBox.checked) {
      tempCategoryFilterList.push(ategoriesCheckBox.id);
    }
  });
  
  let index: number = 0;
  tempFilterdProduts.forEach(fProduct =&gt; {
    if(tempCategoryFilterList.includes(fProduct.CategegoryId)){
      itemsToDelete.push(index);
    }
    index++;
  });
  for(var i = itemsToDelete.length-1; i &gt;= 0; i--){
    tempFilterdProduts.splice(itemsToDelete[i], 1);
  }
  this.filterdProduts = tempFilterdProduts;
  </code></pre>
  <p>}</p>