1
我需要從這個對象中刪除蔬菜從對象,它是一個對象
"shop":
{
"items":
{
"fruits" : [],
"vegetables" :[]
}
}
}
我試圖通過「刪除shop.items.fuits」刪除裏面刪除鍵...但因此未工作
我需要從這個對象中刪除蔬菜從對象,它是一個對象
"shop":
{
"items":
{
"fruits" : [],
"vegetables" :[]
}
}
}
我試圖通過「刪除shop.items.fuits」刪除裏面刪除鍵...但因此未工作
這似乎是工作...
const o = { a: { b: { c: [], d: 4 } } }
delete o.a.b.c
console.log(o)
.as-console-wrapper { max-height: 100% !important; top: 0; }
可能的複製[如何刪除嵌套的屬性?](https://stackoverflow.com/questions/13234301/how-to-remove-nested-attributes) –
如果問題中的代碼是正確的,你缺少蔬菜屬性的引號。 – DD84