js數組去重

  var a = [0,2,3,4,4,0,2];
        for(var i=0,arr={},tmp=[],count=0,l=a.length;i<l;i++){
                if(o[a[i]]){
                        count++;
                }else{
                        arr[a[i]]=1;
                        tmp.push(arr[i])
                }
        }
        alert(count);
        alert(tmp)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章