javascript find substring in string code example
Example 1: check for substring javascript
const string = "javascript";
const substring = "script";
console.log(string.includes(substring)); //true
Example 2: js string search
var str = "This is a test sentence";
var hasTest = str.includes("test");
if(hasTest == true){
//do a thing
}
Example 3: indexof javascript
Array.indexOf(searchElement, fromIndex)