Within the array of nested objects provided below:
[
{
"items": [
{
"name": "See data",
"href": "/data",
},
{
"name": "Account",
"href": "/account",
"icon": {}
}
]
},
{
"items": [
{
"name": "name",
"href": "/name",
"icon": {}
},
{
"name": "My Rooms",
"href": "/rooms",
"icon": {}
}
]
},
{
"items": [
{
"name": "user",
"href": "/user",
"icon": {}
}
]
}
]
Is there a way to remove an object inside by specifying its name?
For instance, removing the object with the name "Account"?
One approach is delete myData[0].items[1];
but this method seems fixed.
Another attempt involved:
myData[0].items = myData[0].items.filter(function (item) {
return item.name !== 'Account';
});