Skip to content

String.contains method

String › contains

Official

Checks if the string contains a specific substring.

Signature:

contains(target: string): boolean

Parameters:

Parameter Type Description
target string The substring to check for.

Returns: booleantrue if the string contains the substring, false otherwise.

Example:

console.log('foo'.contains('oo')); // true
console.log('foo'.contains('bar')); // false