Removing elements with Array.map in JavaScript

后端 未结 8 2060
无人及你
无人及你 2020-12-08 12:43

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)
{
            


        
8条回答
  •  时光取名叫无心
    2020-12-08 13:08

    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.

提交回复
热议问题