This article mainly introduces the JavaScript in the LastIndexOf () method of using the detailed, is the basic knowledge of JS learning, need friends can refer to the
This method calls a string object that returns the value specified by the index last occurrence, begins the search in the Fromindex or returns 1 if the value is not found.
Grammar
?
1 |
String.LastIndexOf (searchvalue[, Fromindex]) |
The following are the details of the parameters:
Searchvalue: A string that represents the value to search for
Fromindex: The position within the calling string, from the start of the search. It is an arbitrary integer length of 0-string. The default value is 0.
return value:
Returns the last occurrence of the index, or 1 if not found
Example:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17-18 |
|
This will produce the following results:
?
1 2 |
LastIndexOf found string:29 LastIndexOf found string:15 |