Description

Return the value of the first element that passes a test provided by the expression.

Syntax

find(array, element, expression)

Parameters

Input ParameterTypeDescription
arrayArrayThe array find() was called upon
elementanyThe current element being processed in the array
expressionexpressionA boolean expression to be run for each array element.

Return value

Type
any

Sample

ExampleResultDescription
find([1, 2, 3, 4], x, x > 2)3Returns the first element that satisfies the test
find([{'name' : 'John', 'age' : 18},{'name' : 'Raj', 'age' : 25}, {'name' : 'Arun', 'age' : 20}], x, x.age > 18){'name' : 'Raj', 'age' : 25}Returns the first user account with age greater than 18

To view all the List functions, click here.

See Also

min
max