English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
includes()Method to determine if one string can be found in another string.
If the string contains a character, the includes() method will returntrue,Otherwise, it returnsfalse.
Note:This method is case-sensitive.
string.includes(searchValue, start)
var str = 'Air Pollution is introduction of chemicals to the atmosphere'; str.includes('Pollution39;); // trueTest and see‹/›
The numbers in the table specify the first browser version that fully supports the include() method:
Method | |||||
includes() | 41 | 40 | Yes | 9 | 12 |
Parameter | Description |
---|---|
searchValue | (Required) The string to be searched in this string |
start | (Optional) Start searching in the stringposition of searchValue(Default is 0) |
Return value: | If the search string is found at any position within the given stringtrue;otherwisefalse |
---|---|
JavaScript version: | ECMAScript 6 |
Check if the string contains "Air", from position2Start searching:
var str = 'Air Pollution is introduction of chemicals to the atmosphere'; str.includes('Air', 2); // falseTest and see‹/›