Remove Object from Array using JavaScript

前端 未结 29 2848
南笙
南笙 2020-11-22 10:24

How can I remove an object from an array? I wish to remove the object that includes name Kristian from someArray. For example:

som         


        
29条回答
  •  情书的邮戳
    2020-11-22 10:43

    If you wanna access and remove object of an array simply you can try something like this.

    // inside some function
    
    let someArray = [ {"ColumnName" : "a", "PropertySerno" : 100005,"UpdateType" : 1},
                      {"ColumnName" : "b", "PropertySerno" : 100202,"UpdateType" : 1,
            "ShowRemoveButton" : true} ];
            
            for (let item of someArray) {
              delete item.ShowRemoveButton;
            }
            console.log(item.outputMappingData.Data);
            
    //output will be like that = [ {"ColumnName" : "a", "PropertySerno" : 100005,"UpdateType" : 1},
    //                             {"ColumnName" : "b", "PropertySerno" : 100202,"UpdateType" : 1 }];
            

提交回复
热议问题