js如何从数组删除某些属性




var orderList=  [
{
"item_id":"121",
"label":"["茄子","打击我气的"]",
"remarks":"",
"title":"测试小程序商品",
"sales_num":null,
"img_url":"https://haibeimaster.oss-cn-hangzhou.aliyuncs.com/__liemi__/image/jpeg/ABFXZMNT01234678_1598588753.jpg",
"price":"100.00",
"old_price":"200.00",
"num":5
},
{
"item_id":"111",
"label":"["发电房","按时散","投入桃仁"]",
"remarks":"555",
"title":"九",
"sales_num":"1",
"img_url":"https://haibeimaster.oss-cn-hangzhou.aliyuncs.com/liemi/09701DCE-A832-4401-99B6-46B072EA40DA.jpg",
"price":"1000.00",
"old_price":"1000.00",
"num":12
}
]

var arr= orderList.filter(item => delete item.label&&delete item.remarks&&delete item.remarks&&delete item.price&&delete item.img_url&&delete item.sales_num&&delete item.old_price&&delete item.title)

cons.log(arr)//[{"item_id":"121","num":5},{"item_id":"111","num":12}]

 

匿名

发表评论

匿名网友