const string = "foo";
const substring = "oo";
console.log(string.includes(substring));
=======================================================
ie support
var string = "foo";
var substring = "oo";
console.log(string.indexOf(substring) !== -1);
https://stackoverflow.com/questions/1789945/how-to-check-whether-a-string-contains-a-substring-in-javascript
沒有留言:
張貼留言