delete a object from array 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); //ES6
// [
// { id: 1, name: 'serdar' },
// { id: 300, name: 'brittany' }
// [
Example 2: javascript delete object from array
someArray.splice(x, 1);