I am trying to remove the first object from an array but somehow I am not able to delete the first object here is my code can you please help?
var arr = [
{
demo: [
{
label: "NOT - Notification",
id: "NOT",
subTree: null,
},
{
label: "LIM - Limitation",
id: "LIM",
subTree: null
},
],
},
];
var ind = arr.findIndex(function (element) {
return element.demo?.id === "NOT";
});
if (ind !== -1) {
arr.splice(ind, 1);
}
console.log('this is new', arr);
If you have any better solution then feel free to drop will appreciate your help.