ECMAScript 6 introduced String.prototype.includes:

const string = "foo";
const substring = "oo";

console.log(string.includes(substring)); // true

String.prototype.includes is case-sensitive and is not supported by Internet Explorer without a polyfill.

In ECMAScript 5 or older environments, use String.prototype.indexOf, which returns -1 when a substring cannot be found:

var string = "foo";
var substring = "oo";

console.log(string.indexOf(substring) !== -1); // true

🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › String › includes
String.prototype.includes() - JavaScript | MDN
The includes() method of String values performs a case-sensitive search to determine whether a given string may be found within this string, returning true or false as appropriate.
🌐
W3Schools
w3schools.com › jsref › jsref_includes.asp
JavaScript String includes() Method
❮ Previous JavaScript String ... text.includes("world"); Try it Yourself » · More examples below. The includes() method returns true if a string contains a specified string....
Discussions

How to check whether a string contains a substring in JavaScript? - Stack Overflow
Example: es6 includes returns false for "abc".includes("ab", "1") this polyfill will return true 2021-02-02T15:34:57.623Z+00:00 ... Another alternative is KMP (Knuth–Morris–Pratt). The KMP algorithm searches for a length-m substring in a length-n string in worst-case O(n+m) time, compared to a worst-case of O(n⋅m) for the naive algorithm, so using KMP may be reasonable if you care about worst-case time complexity. Here's a JavaScript ... More on stackoverflow.com
🌐 stackoverflow.com
contains vs includes javascript?
There's no 'contains' method on strings in Javascript . More on reddit.com
🌐 r/learnjavascript
2
3
September 7, 2018
Why includes() works with a string?
Hello, In MDN doc : " The includes() method determines whether an array includes a certain value among its entries, returning true or false as appropriate." But If I use a string: let string = 'string' console.log(str… More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
1
0
February 21, 2022
(Silly?) inferencing issue/question for Array.includes()
There is a difference between Array and Array | Array (and it's similar with other generics). includes method for the former requires type A | B while for the latter A & B. That's been an issue for years now - don't have a GitHub issue link right now, as I'm on mobile, but should be easily findable. Will post more explanation once I get in front of my PC More on reddit.com
🌐 r/typescript
12
9
January 25, 2022
🌐
Educative
educative.io › answers › what-is-stringincludes-method-in-javascript
What is String.includes() method in JavaScript?
The string.includes() method is used to find out if a string contains a particular substring.
🌐
Career Karma
careerkarma.com › blog › javascript › javascript string contains: step-by-step guide
JavaScript String Contains: Step-By-Step Guide | Career Karma
December 1, 2023 - In this tutorial, we’re going ... JavaScript includes() method, introduced in ES6, determines whether a string contains the characters you have passed into the method....
🌐
Mimo
mimo.org › glossary › javascript › includes-method
JavaScript includes() method: Syntax, Usage, and Examples
The JavaScript includes method helps you quickly determine if a string contains a substring or if an array contains a value. It’s an essential tool in modern JavaScript—cleaner than index-based methods, easier to read, and ideal for conditions, filters, and validation.
Find elsewhere
🌐
TechOnTheNet
techonthenet.com › js › string_includes.php
JavaScript: String includes() method
This JavaScript tutorial explains how to use the string method called includes() with syntax and examples. In JavaScript, includes() is a string method that determines whether a substring is found in a string.
🌐
Medium
medium.com › nerd-for-tech › basics-of-javascript-string-includes-method-107b6094f00b
Basics of Javascript · String · includes() (method) | by Jakub Korch | Nerd For Tech | Medium
June 4, 2021 - The includes() method performs a case-sensitive search to determine whether a specified string may be found within the searched string. Returning value can either be true or false based on a result of search.
🌐
freeCodeCamp
forum.freecodecamp.org › javascript
Why includes() works with a string? - JavaScript - The freeCodeCamp Forum
February 21, 2022 - Hello, In MDN doc : " The includes() method determines whether an array includes a certain value among its entries, returning true or false as appropriate." But If I use a string: let string = 'string' console.log(str…
🌐
JavaScript in Plain English
javascript.plainenglish.io › 10-ways-to-check-if-a-string-contains-substring-in-javascript-91639d81b7
10 Ways To Check If A String Contains Substring In JavaScript | by Sam C. Tomasi | JavaScript in Plain English
November 23, 2022 - const string = "Hello World!"; const substring = "HeLLo"; console.log(string.toLowerCase().includes(substring.toLowerCase())); // true ... New JavaScript and Web Development content every day.
🌐
PTC Community
community.ptc.com › t5 › ThingWorx-Developers › Using-includes-on-a-string-never-works › td-p › 628132
Solved: Using .includes() on a string never works - PTC Community
September 24, 2019 - Whenever I attempt to use the '.includes()' method on string in ThingWorx composer, I always get an error saying that the .includes method can not be found on the object. I even log the type of the variable that I am trying to edit, just to make sure it is in fact a string.
🌐
tutorialstonight
tutorialstonight.com › javascript-string-includes
JavaScript String includes(): Check if string have a substring
The method is applied on a string and the search string is passed as an argument in the method, if the calling string contains the search string then it returns true else returns false. Note: The includes() method is case-sensitive.
🌐
Programiz
programiz.com › javascript › library › string › includes
Javascript String includes()
// check if message includes the string "Java" let result = message.includes("Java"); console.log(result); // Output: true
🌐
TutorialsPoint
tutorialspoint.com › home › javascript › javascript string includes method
JavaScript String Includes Method
September 1, 2008 - The JavaScript String includes() method searches for the part of the string and determines whether the specified string is found in the original string.
🌐
Reality Ripple
udn.realityripple.com › docs › Web › JavaScript › Reference › Global_Objects › String › includes
String.prototype.includes() - JavaScript
if (!String.prototype.includes) { String.prototype.includes = function(search, start) { 'use strict'; if (search instanceof RegExp) { throw TypeError('first argument must not be a RegExp'); } if (start === undefined) { start = 0; } return this.indexOf(search, start) !== -1; }; }
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-string-includes-method
JavaScript String includes() Method - GeeksforGeeks
The includes() method is used to check whether a string contains a specific value. It returns a boolean result based on whether the text is found or not. Returns true if the string contains the specified value.
Published   January 16, 2026
🌐
Tabnine
tabnine.com › home › how to use the includes() method in javascript
How to Use the includes() Method in JavaScript - Tabnine
July 25, 2024 - The includes() method is part of both the Array and String prototypes. This method accepts a search value as a parameter, and returns true if the value is either contained in the array on which it is called, or if it exists as a substring of the string object on which it is called...