indexOf indexOf
Returns the position (in the first argument) of the first occurrence of the second parameter. Returns -1 if there is no match.
Category
String
Function syntax
indexOf(<parameters>)
Parameters
Parameter
Type
string
String
specified value
String
Signature and returned type
indexOf(<string>,<string>)
Returns an integer.
Example
indexOf("Hello", "l")
Returns 2.
Explanation:
In “Hello”, the first occurrence of “l” is at position 2.
recommendation-more-help
8fe209f2-717b-4d36-904c-71a9532007af