Hello Friends 👋,

Welcome To Infinitbility! ❤️

To check if a string contains a substring in typescript, just use the .includes() method it will check and return the result as a boolean based on whether the substring is available on a string or not.

This tutorial will help you to check substring is present or not in a string using typescript syntax examples. here we are using the .includes() method to check substring available in string.

Let start today tutorial How to check a substring in a string in typescript?

The .includes() method return true and false based on string avalablity.

Let create the first example string and substring variable with data.

let str: string = "We have the ability to build infinite way for us --infinitbility";
let subStr: string = "build";

For check substring in a string let use the .includes() method.

str.includes(subStr);  // true

output

includes, typescript, Example