判断obj对象是否在arr数组里面,是返回true constdealArray=(arr,obj)=>{Array.prototype.S=String.fromCharCode(2);Array.prototype.in_array=function(e){varr=newRegExp(this.S+e+this.S);return(r.test(this.S+this.join(this.S)+this.S));};return(arr.in_array(obj))} indexOf用法 varstr="123...
js判断一个数组是否包含另一个数组(一维数组) let a= [1,2,3,4]; let b= [1,2,3] let result= b.every(item => (a.includes(item)));//b的所有值 是否包含于aconsole.log(result);//truelet result2 = a.every(item => (b.includes(item)));//a的所有值 是否包含于bconsole.log(result...
判断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 ...
js判断一个数组是否包含另一个数组(一维数组) let a= [1,2,3,4]; let b= [1,2,3] let result= b.every(item => (a.includes(item)));//b的所有值 是否包含于aconsole.log(result);//truelet result2 = a.every(item => (b.includes(item)));//a的所有值 是否包含于bconsole.log(result...