Мне нужна функция для удаления какого-либо целого объекта внутри массива:
let selectedItem = { LinkID: 1 };
let sindecs = [
{
estado: { id: 2, siga: "AL", nome: "Alagoas" },
link: [
{ LinkID: 1, Link: "link1", Active: false },
{ LinkID: 2, Link: "link 2", Active: false }
],
SindecID: 3
},
{
estado: { id: 19, siga: "RJ", nome: "Rio de Janeiro" },
link: [{ LinkID: 3, Link: "rio", Active: false }],
SindecID: 4
}
];
функция removeLinkObj (sindecs, selectedItem) {
// I need to fill here with a function to remove the selectedItem that match with === sindecs.link.LinkID
}
removeLinkObj (sindecs, selectedItem)
Результат должен быть:
let sindecs = [
{
estado: { id: 2, siga: "AL", nome: "Alagoas" },
link: [
//REMOVED LINE
{ LinkID: 2, Link: "link 2", Active: false }
],
SindecID: 3
},
{
estado: { id: 19, siga: "RJ", nome: "Rio de Janeiro" },
link: [{ LinkID: 3, Link: "rio", Active: false }],
SindecID: 4
}
];