开发者

String contains another string [duplicate]

This question already has answers here: How to check whether a string contains a substring in JavaScript? (3 answers) Closed 9 years ago.

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) {

}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜