This method is like find except that it returns the key of the first element predicate returns truthy for instead of the element itself.
find
predicate
The object to inspect.
The function invoked per iteration.
Returns the key of the matched element, else undefined.
undefined
1.1.0
find, findIndex, findLast, findLastIndex, findLastKey
const users = { 'barney': { 'age': 36, 'active': true }, 'fred': { 'age': 40, 'active': false }, 'pebbles': { 'age': 1, 'active': true }}findKey(users, ({ age }) => age < 40)// => 'barney' (iteration order is not guaranteed) Copy
const users = { 'barney': { 'age': 36, 'active': true }, 'fred': { 'age': 40, 'active': false }, 'pebbles': { 'age': 1, 'active': true }}findKey(users, ({ age }) => age < 40)// => 'barney' (iteration order is not guaranteed)
This method is like
findexcept that it returns the key of the first elementpredicatereturns truthy for instead of the element itself.