js中怎样判断一个字符串等于另一个字符串

如题所述

比如indexOf()方法,注意O是大写。
var test="this is a test";
if(test.indexOf("test")!=-1){
//不等于-1表示该字符串包含子字符串。
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2017-07-24
if (str1 == str2){}
str1和str2表示字符串
相似回答