Wednesday, February 3, 2016

javascript - String contains another string




How can I check if a string contains another string instead of using "==" to compare the whole string?



Regards


Answer



You can use .indexOf():



if(str.indexOf(substr) > -1) {

}

No comments:

Post a Comment