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=是

相关文章:

  • 2021-09-20
猜你喜欢
  • 2022-01-07
  • 2022-01-07
  • 2021-05-20
  • 2022-12-23
  • 2022-02-28
  • 2022-01-07
相关资源
相似解决方案