String.contains method
String › contains
Official
Checks if the string contains a specific substring.Signature:
contains(target: string): booleanParameters:
| Parameter | Type | Description |
|---|---|---|
| target | string | The substring to check for. |
Returns: boolean — true if the string contains the substring, false otherwise.
Example:
console.log('foo'.contains('oo')); // trueconsole.log('foo'.contains('bar')); // false