Home »
JavaScript
String includes() Method with Example in JavaScript
JavaScript String includes() Method: Here, we are going to learn about the includes() method of the string in JavaScript with Example.
Submitted by Shivang Yadav, on February 16, 2020
JavaScript | String includes() Method
The String.includes() method in JavaScript is used to check if the character is present in the string or not. The method returns True if characters are present in the string else it will return False.
The method treats upper and lowercase characters differently.
Syntax
String.includes(search_character, startindex);
Parameters
The method accepts one or two characters, first, is the character needed to be found in the string. The second one is optional which is the index from where the search is started.
Return Value
The return type of this method is boolean.
Browser support:
Chrome, Internet explorer, Mozilla, Safari, Opera mini.
Example
str = "IncludeHelp"
//"IncludeHelp"
str.includes("k")
//false
str.includes("inc")
//true
str.includes("H", 9)
//false
JavaScript String Object Methods »