array.lastIndexWhere()

Get the index of the last Array element that matches the predicate.

Signature

lastIndexWhere(predicate: () => Boolean | Null) => Number | Null

lastIndexWhere(predicate: () => Boolean | Null, end: Number) => Number | Null

Description

The lastIndexWhere() method returns the Array index of the element that matches the predicate.

Parameters

Parameter Type Required Description

predicate

Function

Yes

Function to search for a matching element.

end

Function

Search right-to-left for a match beginning at end, inclusive.

Return value

Type Description

Number

Index of element that matches predicate or null if a match isn’t found.

Examples

['a', 'b', 'c', 'b'].lastIndexWhere(v => v == 'b')
3

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!