Finds an object in an array by matching the value set on the key
Example:
import { findByKey } from "@thalesrc/js-utils/array"; const array = [{a: 1}, {a: 2}, {a: 3}]; findByKey(array, "a", 2); // {a: 2}
Prototype Example:
import "@thalesrc/js-utils/array/proto/find-by-key"; const array = [{a: 1}, {a: 2}, {a: 3}]; array.findByKey("a", 2); // {a: 2}
Collection of the objects
Key to search the value on
Value to match for the key
Found object or undefined
Generated using TypeDoc
Find By Key
Finds an object in an array by matching the value set on the key
Example:
import { findByKey } from "@thalesrc/js-utils/array"; const array = [{a: 1}, {a: 2}, {a: 3}]; findByKey(array, "a", 2); // {a: 2}
Prototype Example:
import "@thalesrc/js-utils/array/proto/find-by-key"; const array = [{a: 1}, {a: 2}, {a: 3}]; array.findByKey("a", 2); // {a: 2}