includes() String Method in JavaScript

Use the includes() method to search for a substring inside a string:

var word = "bravery";

console.log(word.includes(β€œrave”));

// true

Syntax

This quick and easy way to check if one string contains another is very simple to implement. Just call the method with the substring you’re looking for as the argument:

myString.includes(subString);

Case-Sensitive

Remember that the comparison takes cases into consideration:

var burnIntro = β€œYo momma ~”;

console.log(burnIntro.includes(β€œyo”));

// false
✖ Clear

πŸ•΅ Search Results

πŸ”Ž Searching...