String.prototype.includes()
String.prototype.includes() is a JavaScript method in the String category. Checks if a string contains a specified substring. The syntax is str.includes(searchString, position). It returns A boolean. A typical example: "Hello World".includes("World") // true. Another practical use — Search for substring: const email = 'user@example.com' console.log(email.includes('@')) // true console.log(email.includes('gmail')) // false Its time complexity is O(n), which matters when it runs over large inputs. The TypeScript signature is (searchString: string, position?: number): boolean. 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.indexOf(), which returns the index of the first occurrence of a specified value. 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.indexOf(), String.prototype.lastIndexOf(), String.prototype.match(), String.prototype.matchAll(), String.prototype.replace().