includes Method (String) (JavaScript)

Returns a Boolean value that indicates whether the passed in string is contained in the string object.

Syntax

stringObj.includes(substring [, position]);  

Parameters

stringObj
Required. The string object to test against.

substring
Required. The string to test.

position
Optional. The position of the first character to test against in the string object, starting with 0.

Return Value

If the passed in string is contained in the string object, the includes method returns true; otherwise, it returns false.

Remarks

Example

// Returns true   
"abcde".includes("cd")  
"abcde".includes("cd", 2)  

// Returns false  
"abcde".includes("CD")  
"abcde".includes("cd", 3)  

Requirements

Supported in Microsoft Edge (Edge browser). Also supported in Store apps (Microsoft Edge on Windows 10). See Version Information.
Not supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards, Internet Explorer 11 standards. Not supported in Windows 8.1.