How to check if one one string contains another string in Javascript

To check if one one string contains another string in Javascript you can use the following method.

Sample JS

if(testString.indexOf("substring") > -1){
}

Please Share us:
Please rate this snippet

4 thoughts on “How to check if one one string contains another string in Javascript

Leave a Reply