js数组去重

function deleteRepeat(){//删除重复的
               var _arr=[1,1,1,3,3,3,5,8,8,9,10];
               //console.log(_arr);
               for(var i=0;i<_arr.length;i++){
                    for(var n=i+1;n<_arr.length;n++){
                         if(_arr[i]==_arr[n]){
                              _arr.splice(n,1);
                              n--;
                         }
                    }
               }
               console.log(_arr);
          }
          deleteRepeat();
posted @ 2017-02-18 09:06  桐甘桐苦  阅读(152)  评论(0编辑  收藏  举报