findKey es-toolkit
Finds the key of the first element that satisfies the given condition.
Usage
findKey(obj, predicate)
Use findKey when you want to find the key of the first element in an object that satisfies a specific condition. It returns the key for the first value where the condition function returns true.
The condition function receives the current value, key, and the entire object.
Can also be used with complex object structures.
Parameters
The object to search.
A condition function to execute for each element. Finds the key of the first element that returns true.
Returns
The key of the first element that satisfies the condition. Returns undefined if no element satisfies the condition.
Source: es-toolkit
Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.