JavaScript (ES2026) reference · String Methods

JavaScript String includes() Method

Return true if the string contains the given text anywhere. Case-sensitive.

JavaScript (ES2026) Since ES2015

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

string.includes(searchString, position)

Parameters

ParameterDescription
searchString Text to look for.
position optional Index to start searching from. Default: 0

Return value

true or false.

Examples

Contains some text?Try it yourself
const msg = "Payment failed: card declined";
console.log(msg.includes("failed"), msg.includes("Failed"));

Output

true false
Case-insensitive searchTry it yourself
const q = "JAVA";
console.log("JavaScript".toLowerCase().includes(q.toLowerCase()));

Output

true

Version history

VersionChange
JavaScript ES2015Added

In other languages

Was this page helpful?