标签云

微信群

扫码加入我们

WeChat QR Code

Possible Duplicates:
Check if text is in a string
JavaScript: string contains

I'm trying to check if a string I import into my application has a certain piece of text. I know how to do this with jQuery, but how do I do it with straight up JavaScript?


duplicate of stackoverflow.com/questions/1789945/…

2018年07月17日09分20秒

Here a benchmark for the most common ways to check if a string is in a string: jsben.ch/#/o6KmH

2018年07月17日09分20秒

What if the string starts with "World"? The operator should probably be >= 0.

2018年07月18日09分20秒

If I understand correctly, and >=0 value is a match

2018年07月17日09分20秒

I like !== -1 better

2018年07月17日09分20秒