removeById (source code)
- Curried: true
- Failsafe status: alternative available
The removeById
function generates a new array with the item possessing the
specified id removed.
id
: The id of object to be removed.entityArray
: The array of objects from which the object with given id will be removed.
const array = [
{ id: 1, name: "Sam" },
{ id: 2, name: "Oliver" },
];
const idOfItemToBeRemoved = 2;
removeById(idOfItemToBeRemoved, array);
// [{ id: 1, name: "Sam" }]