# Removing items from an Array in for loop

**URL:** <https://forum.kirupa.com/t/removing-items-from-an-array-in-for-loop/301448>\
**Category:** flash\
**Created:** [December 9, 2009, 1:41pm UTC](https://forum.kirupa.com/t/removing-items-from-an-array-in-for-loop/301448 "2009-12-09T13:41:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![IQAndreas](https://avatars.discourse-cdn.com/v4/letter/i/f08c70/32.png) [@IQAndreas](https://forum.kirupa.com/u/IQAndreas)\
**Post date:** [December 9, 2009, 1:41pm UTC](https://forum.kirupa.com/t/removing-items-from-an-array-in-for-loop/301448/1 "2009-12-09T13:41:35Z")

</div>

This is not a question of what command to use. I could _pop, shift, splice or slice_ it out of there (hey, that had a nice ring to it…)

My question is how to properly remove items from an array while in the middle of a for loop:

```auto
//This will cause errors, because if the condition is met, it will skip the next array in line
for (var i:int = 0; i < arr.length; i++)
{
   if (arr*.alpha <= 0)
   {
      arr.splice(i, 1);
   }
}

```

So, what is the most common workaround? This might work:

```auto
//This will cause errors, because if the condition is met, it will skip the next array in line
for (var i:int = 0; i < arr.length; i++)
{
   if (arr*.alpha <= 0)
   {
      arr.splice(i, 1);
      i--;
   }
}

```

Silly question, but is this the ideal or most common way to do it? If someone is reading through my code, will they understand what I am doing without me having to clarify with comments each time?
