标签云

微信群

扫码加入我们

WeChat QR Code

This question already has an answer here:

I want to check if string b is completely contained in string a.
I tried:

var a = "helloworld";
var b = "wold";
if(a.indexOf(b)) { 
    document.write('yes'); 
} else { 
    document.write('no'); 
}

The output is yes, it is not my expected output, because string b(wold) is not completely contained in string a(helloworld) --- wold v.s. world

Any suggestion to check the string?


related: Method like String.contains() in JavaScript

2018年07月17日09分44秒