javascript lastIndexOf() method
Translation results:
last
英[lɑ:st] 美[læst]
n.last;end;last;shoe last (model for making shoes)
vt. Withstand; after...; enough; enough to maintain (especially for a certain period of time)
adj. The last; the nearest; the least likely; the only remaining one
vi.Continue
adv.Last; last time, most recent time
Third person singular: lasts Present participle: lasting Past tense: lasted Past participle: lasted
index
UK[ˈɪndeks] US[ˈɪnˌdɛks]
n.index;<number>index;indication;sign
vt .Index...;Index...;[Economics]Adjust by living index (wages, prices, etc.)
vi.[Mechanics]Transposition
Third person singular: indexes plural: indices indexes present participle: indexing past tense: indexed past participle: indexed
of
##英[əv] 美[ʌv] prep.About;belonging to;made ofjavascript lastIndexOf() methodsyntax
Function: Returns the last occurrence position of a specified string value, and searches from back to front at the specified position in a string.
Syntax: stringObject.lastIndexOf(searchvalue,fromindex)
Parameters: searchvalue Required. Specifies the string value to be retrieved. fromindex Optional integer parameter. Specifies the position in the string to begin searching. Its legal values are 0 to stringObject.length - 1. If this parameter is omitted, the search will start from the last character of the string.
Return: If there is a searchvalue before the fromindex position in stringObject, the position of the last searchvalue that appears is returned.
Description: This method will retrieve the string stringObject from end to beginning to see if it contains the substring searchvalue. The starting position of the search is at fromindex of the string or at the end of the string (when fromindex is not specified). If a searchvalue is found, the position of the first character of searchvalue in stringObject is returned. Character positions in stringObject start from 0.
Note: lastIndexOf() method is case-sensitive! If the string value to be retrieved does not appear, the method returns -1.
javascript lastIndexOf() methodexample
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <script type="text/javascript"> var str="Hello world!" document.write(str.lastIndexOf("Hello") + "<br />") document.write(str.lastIndexOf("World") + "<br />") document.write(str.lastIndexOf("world")) </script> </body> </html>
Run instance »
Click the "Run instance" button to view the online instance