js数组去重1

/*IE9以下不支持indexOf。所以重新写indexOf方法*/
if( !Array.prototype.indexOf ){
    Array.prototype.indexOf = function( item ){
        var res =-1, a_index = null;
        if( this.length == 0 ){
            return res;
         }
        
        for(var i=0; i<this.length; i++){
            a_index = this[i];
            if( a_index == item ){
                res = i;
                break;
            }          
       } 
    
         return res;
    }
}    



function quChong( arr ){
     var newArr = [];
     for(var i=0; i<arr.length; i++){
      if( newArr.indexOf(arr[i]) == -1 ){
           newArr.push( arr[i] );
      }  
   } 
    return newArr; 
}

  

原文地址:https://www.cnblogs.com/fuxiang-yang/p/4953400.html