how to remove an object in an array of objects based on key value code example
Example 1: js remove object from array by value
let originalArray = [
{name: 'John', age: 23, color: 'red'},
{name: 'Ann', age: 21, color: 'blue'},
{name: 'Mike', age: 13, color: 'green'}
];
let filteredArray = originalArray.filter(value => value.age > 18);
Example 2: how to find and remove object from array in javascript
var id = 88;
for(var i = 0; i < data.length; i++) {
if(data[i].id == id) {
data.splice(i, 1);
break;
}
}