Say I have this code
var arr = [{id:1,name:\'a\'},{id:2,name:\'b\'},{id:3,name:\'c\'}];
and I want to remove the item with id = 3 from the array. Is th
Use can use plain JavaScript's Array#filter method like this:
var arr = [{id:1,name:'a'},{id:2,name:'b'},{id:3,name:'c'}];
var filteredArr = arr.filter(obj => obj.id != 3);
console.log(filteredArr);
Or, use Array#reduce and Array#concat methods like this:
var arr = [{id:1,name:'a'},{id:2,name:'b'},{id:3,name:'c'}];
var reducedArr = arr.reduce((accumulator, currObj) => {
return (currObj.id != 3) ? accumulator.concat(currObj) : accumulator;
}, []);
console.log(reducedArr);
NOTE: