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?
.includes() method return
false based on string avalablity.
Let create the first example string and substring variable with data.
1let str: string = "We have the ability to build infinite way for us --infinitbility";2let subStr: string = "build";
For check substring in a string let use the
1str.includes(subStr); // true
Follow me on Twitter
Join our email list and get notified about new content
No worries, I respect your privacy and I will never abuse your email.
Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.