/

HTML / CSS / JavaScript Tutorial

JavaScript String method: lastIndexOf()

[this page | pdf | back links]

The lastIndexOf() method (when applied to a JavaScript String) returns the position of the last occurrence of a specified string in the string. It is case-sensitive. It returns -1 if the string being searched for is not found.

 

It has the following syntax with the following parameters:

 

string.lastIndexOf(searchstring, start)

 

Parameter

Required / Optional

Description

searchstring

Required

String to be searched for (searching backwards

start

Optional

(Default is string.length). Position at which to start search

 


NAVIGATION LINKS
Contents | Prev | Next | JavaScript String Variables


Desktop view | Switch to Mobile