我試圖從我的 JSON 檔案中洗掉陣列中的一個物件:
let json = [{
"name":"John",
"age":"29"
},
{
"name":"Billy",
"age":"45"
}];
我有一個陣列,其中包含要從 JSON 中洗掉的資料,它只有名稱
let remObj = ['John'];
是否可以僅使用名稱洗掉?
編輯:
我試過切片、拼接和過濾
uj5u.com熱心網友回復:
這對你有用嗎?
let json = [{
"name":"John",
"age":"29"
},
{
"name":"Billy",
"age":"45"
}];
let remObj = ['John'];
const newJson = json.filter(p => !remObj.includes(p.name))
console.log(newJson)
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/495977.html
標籤:javascript json
上一篇:在forEach回圈中繼續
下一篇:從陣列中獲取資訊并將其加載到表中
