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
You can work around this constraint by transforming both the original string and the search string to all lowercase: ... const str = "To be, or not to be, that is the question."; console.log(str.includes("To be")); // true console.log(str.includes("question")); // true console.log(str.includes("nonexistent")); // false console.log(str.includes("To be", 1)); // false console.log(str.includes("TO BE")); // false console.log(str.includes("")); // true ... This page was last modified on Jul 10, 2025 by MDN contributors.
🌐
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.
🌐
freeCodeCamp
forum.freecodecamp.org › javascript
Why includes() works with a string?
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…
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › includes
Array.prototype.includes() - JavaScript | MDN
The includes() method of Array instances determines whether an array includes a certain value among its entries, returning true or false as appropriate.
🌐
W3Schools
w3schools.com › jsref › jsref_includes.asp
W3Schools.com
The includes() method returns true if a string contains a specified string.
Find elsewhere
🌐
Reality Ripple
udn.realityripple.com › docs › Web › JavaScript › Reference › Global_Objects › String › includes
String.prototype.includes() - JavaScript
The includes() method determines whether one string may be found within another string, returning true or false as appropriate. The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://gi...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › String › indexOf
String.prototype.indexOf() - JavaScript | MDN
String.prototype.includes() String.prototype.split() Array.prototype.indexOf() Was this page helpful to you? Yes · No Learn how to contribute · This page was last modified on Jul 10, 2025 by MDN contributors.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Learn_web_development › Core › Scripting › Useful_string_methods
Useful string methods - Learn web development | MDN
Now that we've looked at the very basics of strings, let's move up a gear and start thinking about what useful operations we can do on strings with built-in methods, such as finding the length of a text string, joining and splitting strings, substituting one character in a string for another, ...
Top answer
1 of 16
418

You can use the .some method referenced here.

The some() method tests whether at least one element in the array passes the test implemented by the provided function.

// test cases
const str1 = 'hi hello, how do you do?';
const str2 = 'regular string';
const str3 = 'hello there';

// do the test strings contain these terms?
const conditions = ["hello", "hi", "howdy"];

// run the tests against every element in the array
const test1 = conditions.some(el => str1.includes(el));
const test2 = conditions.some(el => str2.includes(el));
// strictly check that contains 1 and only one match
const test3 = conditions.reduce((a,c) => a + str3.includes(c), 0) == 1;

// display results
console.log(`Loose matching, 2 matches "${str1}" => ${test1}`);
console.log(`Loose matching, 0 matches "${str2}" => ${test2}`);
console.log(`Exact matching, 1 matches "${str3}" => ${test3}`);

Also, as a user mentions below, it is also interesting to match "exactly one" appearance like mentioned above (and requested by OP). This can be done similarly counting the intersections with .reduce and checking later that they're equal to 1.

2 of 16
80

With includes(), no, but you can achieve the same thing with REGEX via test():

var value = /hello|hi|howdy/.test(str);

Or, if the words are coming from a dynamic source:

var words = ['hello', 'hi', 'howdy'];
var value = new RegExp(words.join('|')).test(str);

The REGEX approach is a better idea because it allows you to match the words as actual words, not substrings of other words. You just need the word boundary marker \b, so:

var str = 'hilly';
var value = str.includes('hi'); //true, even though the word 'hi' isn't found
var value = /\bhi\b/.test(str); //false - 'hi' appears but not as its own word
🌐
GitHub
github.com › zloirock › core-js › issues › 588
es.string.includes in IE is forced · Issue #588 · zloirock/core-js
May 1, 2019 - The polyfill on mdn checks also if it is already present: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes#Polyfill
Published   Jun 28, 2019
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › String › startsWith
String.prototype.startsWith() - JavaScript | MDN
July 20, 2025 - String.prototype.includes() String.prototype.indexOf() String.prototype.lastIndexOf() Was this page helpful to you? Yes · No Learn how to contribute · This page was last modified on Jul 20, 2025 by MDN contributors.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › String › match
String.prototype.match() - JavaScript | MDN
If you don't give any parameter and use the match() method directly, you will get an Array with an empty string: [""], because this is equivalent to match(/(?:)/). An Array whose contents depend on the presence or absence of the global (g) flag, or null if no matches are found. If the g flag is used, all results matching the complete regular expression will be returned, but capturing groups are not included.
🌐
Unibo
lia.disi.unibo.it › materiale › JS › developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › String.html
String - JavaScript | MDN
April 27, 2015 - String.prototype.includes() Determines whether one string may be found within another string. String.prototype.endsWith() Determines whether a string ends with the characters of another string.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › String › search
String.prototype.search() - JavaScript | MDN
Polyfill of String.prototype.search in core-js with fixes and implementation of modern behavior like Symbol.search support ... This page was last modified on Jul 10, 2025 by MDN contributors.
🌐
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.
🌐
Codedamn
codedamn.com › news › javascript
JavaScript includes method for String and Array with Examples
June 2, 2023 - For more information and examples, ... the includes() method in JavaScript is a powerful and convenient tool for checking the presence of elements or substrings within strings and arrays....