Skip to content

Latest commit

 

History

History
29 lines (20 loc) · 655 Bytes

findById.md

File metadata and controls

29 lines (20 loc) · 655 Bytes

findById (source code)

  • Curried: true
  • Failsafe status: alternative available

The findById function is used to locate an object within an array based on the provided Id.

Arguments:

  • id: The id of object to be searched.
  • entityArray: The array of objects in which the given id will be searched.

Usage:

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

findById(idOfItemToBeFind, array);
// { id: 2, name: "Oliver" }

See also