Standard built-ins
String.prototype.lastIndexOf()
Finds the last literal match whose starting index does not exceed the normalized position.
Formal Syntax & Structure
javascript syntaxjavascript
text.lastIndexOf(searchString, [position])Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| searchString | String | Literal sequence to locate. |
| position | Number | Largest permitted start index; default searches from the end. |
Return Value
Number
Code-unit index or -1.
Working Example
Example Snippetjavascript
console.log("banana".lastIndexOf("ana"));