Const
Finds the first element in an array matching criteria.
Operates on arrayData passed from previous operations. Supports two search modes:
findProperty
findValue
findPredicate
Returns undefined for foundItem and -1 for foundIndex if no match found.
undefined
foundItem
-1
foundIndex
Operation data with foundItem (the matching element) and foundIndex (its position)
// Find by property equalityconst result = findInArray({ arrayData: [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}], findProperty: 'id', findValue: 2});// result.foundItem = {id: 2, name: 'Bob'}// result.foundIndex = 1 Copy
// Find by property equalityconst result = findInArray({ arrayData: [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}], findProperty: 'id', findValue: 2});// result.foundItem = {id: 2, name: 'Bob'}// result.foundIndex = 1
// Find with custom predicateconst result = findInArray({ arrayData: [10, 25, 30, 45], findPredicate: (item) => item > 30});// result.foundItem = 45// result.foundIndex = 3 Copy
// Find with custom predicateconst result = findInArray({ arrayData: [10, 25, 30, 45], findPredicate: (item) => item > 30});// result.foundItem = 45// result.foundIndex = 3
Finds the first element in an array matching criteria.
Operates on arrayData passed from previous operations. Supports two search modes:
findPropertyandfindValueto find by property matchfindPredicatefunction for complex search logicReturns
undefinedforfoundItemand-1forfoundIndexif no match found.