Skip to content

Latest commit

 

History

History
30 lines (21 loc) · 687 Bytes

removeById.md

File metadata and controls

30 lines (21 loc) · 687 Bytes

removeById (source code)

  • Curried: true
  • Failsafe status: alternative available

The removeById function generates a new array with the item possessing the specified id removed.

Arguments:

  • id: The id of object to be removed.
  • entityArray: The array of objects from which the object with given id will be removed.

Usage:

const array = [
  { id: 1, name: "Sam" },
  { id: 2, name: "Oliver" },
];
const idOfItemToBeRemoved = 2;

removeById(idOfItemToBeRemoved, array);
// [{ id: 1, name: "Sam" }]

See also