Opens in a new tab
A picture of Jeff Brigman
I CODE TODAY FOR
A BETTER TOMORROW

Glossary Term

String.prototype.indexOf()

2 tags 1 category

The indexOf() method of String values searches this string and returns the index of the first occurrence of the specified substring. It takes an optional starting position and returns the first occurrence of the specified substring at an index greater than or equal to the specified number.

Strings are zero-indexed: The index of a string’s first character is 0, and the index of a string’s last character is the length of the string minus 1.

The indexOf() method is case sensitive. For example, the following expression returns -1:

Return value: The index of the first occurrence of searchString found, or -1 if not found.

Syntax example: indexOf(searchString)

Term Connections

Explore related terms connected by shared tags, shared categories, and relationship phrases. This map loads only when it comes into view.

Loading term connections…