1 /*
 2 js数组去掉重复项
 3 var somearray = [1,1,2,2,3,3,4,4,'1'];
 4 somearray.check();
 5 //somearray will return arr=[1,2,3,4,'1']
 6 */
 7 Array.prototype.check= function(){
 8 var tem=[];
 9 this.forEach(function(value){
10 if(tem.indexOf(value)===-1){
11 tem.push(value);
12 }
13 });
14 this.splice(0);
15 this.push.apply(this,tem);
16 }

 注:与数字相同的数字字符无法区分,比如【'1'】和【1】

相关文章:

  • 2021-08-10
  • 2021-11-14
  • 2022-01-19
  • 2021-08-20
  • 2022-01-01
  • 2021-07-19
  • 2022-12-23
  • 2021-11-20
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
  • 2021-10-01
  • 2022-12-23
  • 2022-02-15
相关资源
相似解决方案