蜜豆视频

lastIndexOf lastIndexOf

Returns the position (in the first argument) of the last occurrence of the second parameter. Returns -1 if there is no match.

Category

String

Function syntax

lastIndexOf(<parameters>)

Parameter

Parameter
Type
string
String
specified value
String

Signature and returned type

lastIndexOf(<string>,<string>)

Returns an integer.

Example

lastIndexOf("Hello", "l")

Returns 3.

Explanation:

In 鈥淗ello鈥, the last occurrence of 鈥渓鈥 is at position 3.

recommendation-more-help
b22c9c5d-9208-48f4-b874-1cefb8df4d76