Removing elements with Array.map in JavaScript
问题 I would like to filter an array of items by using the map() function. Here is a code snippet: var filteredItems = items.map(function(item) { if( ...some condition... ) { return item; } }); The problem is that filtered out items still uses space in the array and I would like to completely wipe them out. Any idea? EDIT: Thanks, I forgot about filter() , what I wanted is actually a filter() then a map() . EDIT2: Thanks for pointing that map() and filter() are not implemented in all browsers,