String.prototype.indexOf()
String.prototype.indexOf() is a JavaScript method in the String category. Returns the index of the first occurrence of a specified value. The syntax is str.indexOf(searchValue, fromIndex). It returns the index, or -1 if not found. A typical example: "Hello".indexOf("l") // 2. Its time complexity is O(n), which matters when it runs over large inputs. The TypeScript signature is (searchString: string, position?: number): number. A close sibling is String.prototype.charAt(), which returns the character at the specified index. A close sibling is String.prototype.charCodeAt(), which returns the Unicode value of the character at the specified index. A close sibling is String.prototype.concat(), which concatenates strings together. A close sibling is String.prototype.includes(), which checks if a string contains a specified substring. More about this category: String methods for text manipulation — split, replace, trim, match, and more. Related String methods: String.prototype.charAt(), String.prototype.charCodeAt(), String.prototype.concat(), String.prototype.includes(), String.prototype.lastIndexOf(), String.prototype.match(), String.prototype.matchAll(), String.prototype.replace().