CKTIS / JavaScript
String.prototype.includes — checking for a substring
String.prototype.includes checks whether text contains a given substring and returns true or false. It is case-sensitive, supports a starting position, and does not accept ordinary regular expressions.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
str.includes(searchString)
str.includes(searchString, position)String.prototype.includes searches for a literal substring and returns true or false without changing the text. It is case-sensitive and compares UTF-16 code units: it neither normalizes Unicode nor applies language-specific matching rules.
The optional position specifies the earliest matching start index, counted from zero in UTF-16 code units. It defaults to 0; after numeric conversion, any fractional part is truncated toward zero, and the result is clamped between 0 and the string length. If the method reaches the matching step, an empty searchString returns true, even when the supplied position exceeds the string length. However, position is converted before matching: passing a BigInt as position throws a TypeError even with an empty searchString.
An ordinary RegExp object used as searchString causes a TypeError; formally, the IsRegExp test decides this and takes Symbol.match into account. Other search arguments undergo string conversion, so an omitted argument means searching for "undefined". Calling the method with null or undefined as this causes a TypeError.
This is an ECMAScript standard-library method, not a Web API. Support in a particular browser must be checked separately; availability in Node 24 does not prove browser support.
Examples
const text = "JavaScript";
console.log(text.includes("Script"));
console.log(text.includes("script"));
console.log(text.includes("Java", 1));
console.log(text.includes("", 99));
try {
text.includes(/Script/);
} catch (error) {
console.log(error.name);
}Result
true false false true TypeError
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.