lastIndexOf()
Get the last occurrence of a substring in the string.
Description
The lastIndexOf()
method returns the starting location of last occurrence of
otherString in the index range indicated by position. If position is
positive, the method terminates the search at the zero-based position
index, counting from the left.
Return value
Type | Description |
---|---|
The index location of the last occurring string that matches otherString,
in the range described by position. If an exactly matching string is not
found, the method returns |
Examples
-
Get the location of the last occurrence of the string "200" at or below index location 27:
27
-
Get the location of the last occurrence of the string "200" at or below index location 20:
9
-
Get the location of the last occurrence of the string "200" at or below index location 8, which fails because the string isn’t found:
null
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!