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
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.