Returns the position (in the first argument) of the first occurrence of the second parameter. Returns -1 if there is no match.
String
indexOf(<parameters>)
Parameter | Type |
---|---|
string | String |
specified value | String |
indexOf(<string>,<string>)
Returns an integer.
indexOf("Hello", "l")
Returns 2.
Explanation:
In “Hello”, the first occurrence of “l” is at position 2.