The indexOf(...) function has two variations, not counting syntax variations. It searches for one String value within another String value. It can optionally be instructed to begin searching at a particular character index position. The indexOf(...) function returns -1 if no match is found. If a match is found, it returns the index position of the first character in the matching sub-string. If either of the two input Strings is null, then the result will also be null. If the start-index is null or not present then the function will search from the beginning.

Syntax:
indexOf( source-string, target-string )
indexOf( source-string, target-string, start-index )
source-string.indexOf( target-string )
source-string.indexOf( target-string, start-index )

Parameter Description
source-string

The String within which the search will take place. 

target-string

The String for which to search. 

start-index

The index of the character to begin searching at.