2 回答

TA貢獻1895條經(jīng)驗 獲得超7個贊
您可以使用當(dāng)前對象的filter內(nèi)部和內(nèi)部,Object.keys并檢查它是否包含給定的過濾器:
var MainArray=[ {'First Name': "First Name"}, {'Last Name': "Contact"}, {'Last Name': "Contact"} ];
var result = MainArray.filter(item=>!Object.keys(item).includes('First Name'));
var result2 = MainArray.filter(item=>!item['First Name']);
console.log(result);
console.log(result2);

TA貢獻1799條經(jīng)驗 獲得超9個贊
filter()方法也可用于根據(jù)給定條件刪除項目,請參見以下示例:
let data=[
{"First Name": "First Name"},
{"First Name": "First Name"},
{"Last Name": "Contact"},
{"Last Name": "Contact"}
]
const keyToRemove = "First Name"; //Key to remove
data = data.filter(x => !x[keyToRemove]);
console.log(data);
添加回答
舉報