Top  | Previous | Next

Strings / indexOf

indexOf(string, substring)

Searches for the first occurrence of the substring inside of string. Returns the index of where substring was found, or -1 if it wasn't found.

 

indexOf("Hamburger""urge")

...returns 4

 

indexOf("Test""")

...returns 0

 

indexOf("Disfunctional""fun")

...returns 3

 

indexOf("Disfunctional""marble")

...returns -1

 

indexOf("banana""n")

...returns 2