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
break class const continue debugger do...while for for...in for...of function if...else let return switch throw try...catch var while JS Strings · at() charAt() charCodeAt() codePointAt() concat() constructor endsWith() fromCharCode() includes() indexOf() isWellFormed() lastIndexOf() length localeCompare() match() matchAll() padEnd() padStart() prototype repeat() replace() replaceAll() search() slice() split() startsWith() substr() substring() toLocaleLowerCase() toLocaleUpperCase() toLowerCase() toString() toUpperCase() toWellFormed() trim() trimEnd() trimStart() valueOf() JS Typed Arrays ·
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-how-to-check-whether-a-string-contains-a-substring
JavaScript - How To Check Whether a String Contains a Substring? - GeeksforGeeks
July 23, 2025 - Here are the different methods to check whether a string contains a substring in JavaScript. The includes() method is the most simple and modern way to check if a string contains a specific substring.
🌐
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 - This method allows you to check if a string contains a substring, and returns a boolean value. const string = "Hello World!"; console.log(string.includes("Hello")); // true console.log(string.includes("!")); // true console.log(string.includes("Hello World!")); // true console.log(string.includes("Hello World!!")); // false
🌐
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.
🌐
Appdividend
appdividend.com › check-whether-a-string-contains-a-substring-in-javascript
JavaScript String includes(): Check If a String Contains a Substring
September 12, 2025 - It is a modern approach for string.indexOf() method. const str = "Nvidia Company!"; console.log(str.includes("Nvidia")); // Output: true (found as a contiguous sequence) console.log(str.includes("Apple")); // Output: false · In the above code, ...
Find elsewhere
🌐
Bacancy Technology
bacancytechnology.com › qanda › javascript › string-contains-a-substring-in-javascript
How to Check If a String Contains a Substring in JavaScript
... const str = 'Hello, world!'; ... } else { console.log('Substring not found'); } The includes() method determines whether a string contains the specified substring....
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-string-includes-method
JavaScript String includes() Method - GeeksforGeeks
The includes() method provides a simple true or false result. This result tells whether the given value exists in the string. Returns true if the value is present. Returns false if the value is not found.
Published   March 22, 2018
🌐
Stack Abuse
stackabuse.com › javascript-check-if-string-contains-a-substring
JavaScript: Check if String Contains a Substring
September 6, 2023 - As you can see, a boolean value is returned since the string "stack" is a substring of stackabuse. This is a case sensitive search, so the following will not match the substring: > let str = 'StackAbuse'; > let substr = 'stack'; > str.includes(substr); false
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › String › substring
String.prototype.substring() - JavaScript | MDN
The substring() method of String values returns the part of this string from the start index up to and excluding the end index, or to the end of the string if no end index is supplied. const str = "Mozilla"; console.log(str.substring(1, 3)); // Expected output: "oz" console.log(str.substring(2)); ...
🌐
Mastering JS
masteringjs.io › tutorials › fundamentals › contains-substring
Check if a String Contains a Substring in JavaScript - Mastering JS
const str = 'arya stark'; // The most concise way to check substrings ignoring case is using // `String#match()` and a case-insensitive regular expression (the 'i') str.match(/Stark/i); // true str.match(/Snow/i); // false // You can also convert both the string and the search string to lower case. str.toLowerCase().includes('Stark'.toLowerCase()); // true str.toLowerCase().indexOf('Stark'.toLowerCase()) !== -1; // true str.toLowerCase().includes('Snow'.toLowerCase()); // false str.toLowerCase().indexOf('Snow'.toLowerCase()) !== -1; // false
🌐
30 Seconds of Code
30secondsofcode.org › home › javascript › string › string contains substring
Check if a string contains a substring in JavaScript - 30 seconds of code
July 27, 2022 - It's a simple method that returns a boolean value depending on whether the string contains the substring or not. const str = 'Hello world'; str.includes('world'); // true str.includes('foo'); // false
🌐
Medium
medium.com › @JavaScript-World › javascript-string-contains-mastering-the-includes-method-with-examples-90f92130067b
JavaScript String Contains: Mastering the includes Method with Examples | by JavaScript-World | Medium
May 8, 2023 - In this blog post, we'll delve ... essential string manipulation function. The includes method is a built-in function that determines whether a string contains the specified 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.
🌐
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.
🌐
ReqBin
reqbin.com › code › javascript › vy4txenr › javascript-string-contains-example
How do I check if a string contains a substring in JavaScript?
To check if a string contains a substring in JavaScript, use the string.includes(term, start) method, which checks if the string contains the substring. The first parameter is the string to search for, and the second optional parameter specifies ...
🌐
Zipy
zipy.ai › blog › string-contains-substring-javascript
string contains substring javascript
April 12, 2024 - Understanding these methods is crucial for string manipulation and data validation tasks. The includes() method determines if one string may be found within another string, returning ...
🌐
CoreUI
coreui.io › answers › how-to-check-if-a-string-contains-a-substring-in-javascript
How to check if a string contains a substring in JavaScript · CoreUI
September 22, 2025 - The includes() method searches the string for the specified substring and returns true if found, or false if not found. In this example, 'Hello world'.includes('world') returns true because ‘world’ exists within the string.