String.lastIndexOf() (Method)

The location of the rightmost sub-string within a string.


ECMAScript edition - 2
JavaScript - 1.0
JScript - 1.0
Internet Explorer - 3.02
Netscape - 2.0
Netscape Enterprise server - 2.0
Opera - 3.0
Property/method value type:Number primitive
JavaScript syntax:-myString.lastIndexOf(aSearchString)
-myString.lastIndexOf(aSearchString, aPosition)
Argument list:aPositionAn optional valid character position within the string to indicate the search start. Missing value or 0 indicates the entire string is to be searched
aSearchStringA string to search for within the string object

Locate the rightmost occurrence of the search string within the receiving String object.

If the search string cannot be found, then the value -1 is returned.

If the starting position is not indicated, the entire string will be searched.

The result of this method is the index of the rightmost occurrence of the sub-string or -1 if it is not found.

Example code:

   myIndex = myString.lastIndexOf("AAA");

See also:String.prototype


ECMA 262 edition 2 - section -

ECMA 262 edition 3 - section -