Home » JavaScript Tutorial

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);

Parameter(s):

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





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.