let arr = [1, 2, 3, 4];

if (arr.indexOf('1') > -1) {}    //判断1是否在数组arr中,true=是

 

let str = string;

if (str.indexOf('t') !== -1) {}    //判断字符串string中是否包含"t",true=是

相关文章: