String lastIndexOf() Return value

This method returns the index of the string (0-based) where the searchvalue is found for the last time. If the searchvalue cannot be found in the string then the method returns -1

JavaScript String lastIndexOf() Method

The lastIndexOf() method in JavaScript is used to search for the last occurrence of a specified substring within a string.

It returns the index of the last occurrence of the specified substring, or -1 if the substring is not found.

Similar Reads

String lastIndexOf() Syntax

str.lastIndexOf(searchValue , index)...

String lastIndexOf() Parameters

lastIndexOf() Method accepts 2 parameters which are discussed below:...

String lastIndexOf() Return value

This method returns the index of the string (0-based) where the searchvalue is found for the last time. If the searchvalue cannot be found in the string then the method returns -1...

JavaScript String lastIndexOf() Method Examples

Example 1: Finding Last Occurrence of Substring in JavaScript...

Contact Us