lastIndexOf()

Get the index of the last array element that matches the given value.

Signature

lastIndexOf(value: Any): Number | Null

lastIndexOf(value: Any, index: Number): Number | Null

Description

The lastIndexOf() method returns the array index of the element that matches value.

Parameters

Parameter Type Required Description

value

Any

Yes

Value to search for in the array.

index

Number

Array index to start right-to-left search for matching value, inclusive.

Return value

Type Description

Number

Index of matching element or null if a match isn’t found.

Examples

['a', 'b', 'c', 'b'].lastIndexOf('c')
2

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!