Removing elements with Array.map in JavaScript

后端 未结 8 2081
无人及你
无人及你 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:14

    following statement cleans object using map function.

    var arraytoclean = [{v:65, toberemoved:"gronf"}, {v:12, toberemoved:null}, {v:4}];
    arraytoclean.map((x,i)=>x.toberemoved=undefined);
    console.dir(arraytoclean);
    

提交回复
热议问题