<p>I would like to filter an array of items by using the <code>map()</code> function. Here is a code snippet:</p>

<pre><code>var filteredItems = items.map(function(item)
{
    if( ...some condition... )
    {
        return item;
    }
});
</code></pre>

<p>The problem is that filtered out items still uses space in the array and I would like to completely wipe them out.</p>

<p>Any idea?</p>

<p>EDIT: Thanks, I forgot about <code>filter()</code>, what I wanted is actually a <code>filter()</code> then a <code>map()</code>.</p>

<p>EDIT2: Thanks for pointing that <code>map()</code> and <code>filter()</code> are not implemented in all browsers, although my specific code was not intended to run in a browser.</p>

That's not what map does. You really want
```
Array.filter
```
. Or if you really want to remove the elements from the original list, you're going to need to do it imperatively with a for loop.