remove from array object javascript code example
Example 1: javascript remove object from array
const array = [
{ id: 1, name: 'serdar' },
{ id: 5, name: 'alex' },
{ id: 300, name: 'brittany' }
];
const idToRemove = 5;
const filterArray = array.filter((item) => item.id !== idToRemove);
Example 2: 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 3: javascript remove object from array
var array = ['Object1', 'Object2'];
array.pop(object);
array.shift(object);
array.splice(position, 1);