I assume dashboard_info
from the second code snippet is practically the same as info
from the first snippet
If so you can simply use the delete
keyword in a given property of an object to remove it
So var it= obj["key"]
then delete it
, or simply, in general delete obj["key"]
The thing that makes your case interesting is that it's not just about deleting a known property, it's about deleting, in fact, an entire object, from an array (just thought it would be useful to give the delete
intro in case you also why to modify a property of an object)
To delete an element from an array, you use Array.splice(indexToStartAt, numberOfElementsToCutOut)
So in this case, you would want to do data_content.splice(0,1)
since you went to start deleting at the 0th index, and you only want to delete one element
The thing is though that I'm guessing you want to make this dynamic, such that you want to delete any element from the array whose property "project_name" equals "First", to do that you can traverse the array with a recursive function
var cur=0
function go(str) {
var found = data_content.find(x=>x.project_name==str)
if (found) {
data_content.splice(data_content.indexOf(found),1)
if (++cur < data_content.length)
go(str)
}
}
go("First")