To check a string exists in other string in JavaScript, we can use indexOf function, if exists this function return 》=0 value,otherwise it will return -1.
For example:
if(str.indexOf(substr)>=0){
// exist
} else{
// not exist
}
To check a string exists in other string in JavaScript, we can use indexOf function, if exists this function return 》=0 value,otherwise it will return -1.
For example:
if(str.indexOf(substr)>=0){
// exist
} else{
// not exist
}