String.includes()
AD · 728×90
Google AdSense / Яндекс.Директ
String
String.includes()
Returns true if a string contains a given substring, false otherwise
→ booleanPHP: str_contains()ES7+
stringstring
Source string
searchStringstring
Substring to search for
positionnumberoptional
Position to start searching from
(string).includes(searchString, position)
RESULT
— click Run or press Ctrl+Enter —
Parameter Reference
ParameterTypeStatusDescription
stringstringrequiredSource string
searchStringstringrequiredSubstring to search for
positionnumberoptionalPosition to start searching from
About

includes() returns true if the string contains the specified substring, false otherwise. A more readable alternative to indexOf() !== -1. Case-sensitive. Related: startsWith() checks the beginning, endsWith() checks the end.

Browser Support

Introduced in ES7/ES2016. PHP got str_contains() only in PHP 8.0 (2020). Before ES2016, indexOf() !== -1 was the standard.

Tips & Gotchas