How can I check if a string c开发者_高级运维ontains another string instead of using "==" to compare the whole string?
Regards
You can use .indexOf()
:
if(str.indexOf(substr) > -1) {
}
How can I check if a string c开发者_高级运维ontains another string instead of using "==" to compare the whole string?
Regards
You can use .indexOf()
:
if(str.indexOf(substr) > -1) {
}
精彩评论