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. const sentence = "The quick brown fox jumps over the lazy dog."; const word = "fox"; console.log( `The word "${word}" ...
🌐
W3Schools
w3schools.com › jsref › jsref_includes.asp
W3Schools.com
cssText getPropertyPriority() ... 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
Usually I would expect a String.contains() method, but there doesn't seem to be one. What is a reasonable way to check for this? More on stackoverflow.com
🌐 stackoverflow.com
Is Array.prototype.includes() constant speed or is it a loop?
According to the spec , it is iterating through the array, starting from the first element, iterating over every index of the array (including empty elements in the case of sparse arrays) and proceeding to the last. Not surprisingly, there are best-case conditions (first element is a match) and worst case conditions (no element matches) that will have significant differences in return time. More on reddit.com
🌐 r/javascript
23
14
April 17, 2018
Javascript .includes not working / issues
The value returned by .getElementsByTagName() is not an array, it is a live HTMLCollection . You need to convert it to an array if you want to use array methods on it. Also keep in mind that Array.prototype.includes has poor browser support, so you need to polyfill it. But even then your code won't work. Your code is saying "does this array of elements contain the string "*"" - to which the answer is obviously always no, because there is no case where a element === the string "*". Assuming that the user input is rendered to straight HTML (i.e. the user input isn't inside a or <input>) then you need to check if the .textContent of any of your cells contains the string "*" - how you want to do that depends on how you are in regards to browser support/transpiling to ES5. Assuming cells is your array (not your HTMLCollection), then the ES6 way would be if (cells.some(td => td.textContent.includes("*")) { ... } - while the ES5 way would be a plain ol' for loop to check through each value in the array, checking if .textContent.indexOf("*") !== -1. More on reddit.com
🌐 r/webdev
21
0
August 2, 2018
contains vs includes javascript?
There's no 'contains' method on strings in Javascript . More on reddit.com
🌐 r/learnjavascript
2
3
September 12, 2018
🌐
Vultr Docs
docs.vultr.com › javascript › standard-library › String › includes
JavaScript String includes() - Check Substring Presence | Vultr Docs
November 14, 2024 - The includes() method in JavaScript provides a straightforward approach to verify if a string contains a specific substring.
🌐
freeCodeCamp
freecodecamp.org › news › how-to-check-if-a-string-contains-a-substring-javascript
How to Check if a String Contains a Substring in JavaScript
October 7, 2022 - In this article, you will learn two different ways you can check if a string contains a substring using JavaScript methods. ... How to use the built-in includes() JavaScript method.
🌐
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.
Find elsewhere
🌐
Codedamn
codedamn.com › news › javascript
JavaScript includes method for String and Array with Examples
June 2, 2023 - The includes() method is a built-in JavaScript function that checks if a specific element or substring is present in an array or a string, respectively.
🌐
Attacomsian
attacomsian.com › blog › javascript-includes-method
Check if a string contains a substring using includes() in JavaScript
August 26, 2022 - Introduction to JavaScript String.includes() method. The easiest way to check if a string contains a substring.
🌐
freeCodeCamp
freecodecamp.org › news › javascript-string-contains-how-to-use-js-includes
JavaScript String Contains – How to use JS .includes()
November 5, 2021 - In JavaScript you can use the .includes() method to see if one string is found in another. But how does it work exactly? In this article, I will walk you through a few code examples of the JavaScript string method called .includes(). Basic .includes...
🌐
Mimo
mimo.org › glossary › javascript › includes-method
JavaScript includes() method: Syntax, Usage, and Examples
The includes() method determines whether a string or an array contains a specified value, returning true or false as appropriate. It is case-sensitive. For Arrays: Checks if an array contains a specific element. JSX · Open in Mimo · Open in Mimo · Copy Code · const fruits = ['apple', 'banana', ...
🌐
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.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Template_literals
Template literals (Template strings) - JavaScript | MDN
"youngster" : "centenarian"; // We can even return a string built using a template literal return `${str0}${personExp}${str1}${ageStr}${str2}`; } const output = myTag`That ${person} is a ${age}.`; console.log(output); // That Mike is a youngster. The tag does not have to be a plain identifier. You can use any expression with precedence greater than 16, which includes property access, function call, new expression, or even another tagged template literal. js ·
🌐
Love2Dev
love2dev.com › blog › javascript-includes
JavaScript Includes To Search 🔍 In Strings & Arrays
The JavaScript 👨‍💻 includes method finds 🔍 the target in an Array or String. Learn how to search arrays and strings to determine if they contain your item.
🌐
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.
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › lang › String.html
String (Java Platform SE 8 )
October 20, 2025 - This method works as if by invoking the two-argument split method with the given expression and a limit argument of zero. Trailing empty strings are therefore not included in the resulting array.
🌐
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
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › String
String - JavaScript | MDN
Strings are represented fundamentally as sequences of UTF-16 code units. In UTF-16 encoding, every code unit is exact 16 bits long. This means there are a maximum of 216, or 65536 possible characters representable as single UTF-16 code units. This character set is called the basic multilingual plane (BMP), and includes the most common characters like the Latin, Greek, Cyrillic alphabets, as well as many East Asian characters.
🌐
SheCodes
shecodes.io › athena › 220596-how-to-use-the-includes-method-in-javascript
[JavaScript] - How to use the .includes() method in | SheCodes
Learn how to use the `.includes()` method in JavaScript to check if a specific string or element is present in another string or array. ... How do I make a javascript event where you click on a thumbnail image and it pops up with a full sized image?
🌐
DigitalOcean
digitalocean.com › community › tutorials › js-includes-string-method
includes() String Method in JavaScript | DigitalOcean
August 29, 2016 - Check if a string contains another string in just one line of code in JavaScript with the includes method.
🌐
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....