JS TutorialJavascript-HomeJavascript-IntroductionJavaScript-File-UseJavascript-Output-ExampleJavaScript CommentJavaScript VariableJavaScript OperatorJavaScript ConsoleJavaScript StringJavaScript string splitJavaScript string sliceJavascript trim whitespaceJavaScript string indexOf methodJavaScript string lastIndexOf methodJavaScript DateJavascript conditional statement
JavaScript string lastIndexOf method
JavaScript lastIndexOf method start searching from last to the string and return index of searchValue if searchValue exist in string otherwise return -1
Syntax
string.lastIndexOf(searchValue)
string.lastIndexOf(searchValue,fromIndex)
Example
Parameter Details
| Parameter | Description |
| searchValue | searchValue is a substring that you want to search in string |
| fromIndex | optional - fromIndex decide the index to start searching in reverse order in string |
Technical Details
| Return | lastIndexOf method return index of first searchValue if exist otherwise return -1 |
Browser support
| Browser | |||||
| Version | yes | yes | yes | yes | yes |
Tips - When searchValue(substring) present more than one time in string then lastIndexOf method return index of first searchValue
Example
Note - if searchValue exist in string but not exist in specify in range then lastIndexOf method return -1
Example
lastIndexOf method case-sensitive
lastIndexOf method are case-sensitive searchvalue


