•Find
Returns the first element in the provided array that satisfies provided expression.
•Input parameters object
array
(array: [] any of allowed types)
- List of items.
predicate
text: <required>
- An expression that takes one item as input and returns either true or false based on whether the item satisfies some condition.
•Output parameters object
item
(any of allowed types: <required>)
- Returns the matched element, else undefined.
•Example
array: [
{ 'user': 'barney', 'age': 36, 'active': true },
{ 'user': 'fred', 'age': 40, 'active': false },
{ 'user': 'pebbles', 'age': 56, 'active': true }
]
predicate: 'o => o.age < 40'
output: { 'item': { 'user': 'barney', 'age': 36, 'active': true }}
array: [ { 'user': 'barney', 'age': 36, 'active': true }, { 'user': 'fred', 'age': 40, 'active': false }, { 'user': 'pebbles', 'age': 56, 'active': true }]
predicate: 'o => o.age < 40'
output: { 'item': { 'user': 'barney', 'age': 36, 'active': true }}
•Demo