wwj007

判断obj对象是否在arr数组里面,是返回true

const dealArray = (arr, obj) => {
  Array.prototype.S = String.fromCharCode(2);
  Array.prototype.in_array = function (e) {
    var r = new RegExp(this.S + e + this.S);
    return (r.test(this.S + this.join(this.S) + this.S));
  };
  return (arr.in_array(obj))
}

indexOf用法

var str = "123";
console.log(str.indexOf("3") != -1 );  // true

分类:

技术点:

相关文章:

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