js delete an object from array 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;
}
}
Example 3: how to remove an object from an array javascript
someArray.splice(x, 1);
Example 4: javascript remove object from array
var array = ['Object1', 'Object2'];
array.pop(object);
array.shift(object);
array.splice(position, 1);