Favorites

JavaScript String.prototype.includes() Method

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
String.prototype.includes()
JavaScript String Instance methodThis method is supported by all modern browsers.
Updated 28th November 2026

The includes() method checks whether a string contains another string, returning true or false. The search is case-sensitive.

Description

The includes() method of String values performs a case-sensitive search to find out whether one string appears inside another, and returns true or false. It reads more clearly than the older indexOf(text) !== -1 check.

The search is case-sensitive, so convert both strings with toLowerCase() for a case-insensitive check. To search with a pattern, use RegExp.prototype.test() instead; passing a regular expression to includes() throws a TypeError. Arrays have their own Array.prototype.includes() method, which checks for an element rather than text.

The optional second argument sets the position to start searching from, which lets you check part of a string without slicing it first. An empty search string always returns true, because every string contains the empty string. For a case-insensitive check across languages, compare lower-cased versions of both strings, or use localeCompare() with sensitivity: 'base' for whole-string comparisons.

Syntax

string.includes(searchString)
string.includes(searchString, position)

Parameters

  • searchStringThe text to search for. A regular expression is not allowed.
  • positionOptional. The index to start searching from. Defaults to 0.

Return Value

true if the search string is found anywhere in the string, otherwise false.

Exceptions

  • TypeErrorThrown if searchString is a regular expression.

Example

const sentence = 'The quick brown fox';

console.log(sentence.includes('quick'));
console.log(sentence.includes('Quick'));   // case-sensitive
console.log(sentence.toLowerCase().includes('quick'));
console.log(sentence.includes('The', 1));  // start at index 1

Browser Support

The following information will show you the current browser support for the String.prototype.includes() method. Hover over a browser icon to see the version that first introduced support for this method.

This method is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee