js,數組中去重複對象,和 去屬性

去除重複對象

for(var i =0; i<fileList.length; i++){
     if(!this.obj[fileList[i].name]){
          this.fileList.push(fileList[i]);
         this.obj[fileList[i].name] = true;
       }
  }

去除重複屬性

var arr=[]

for(var i =0; i<fileList.length; i++){
if(this.arr.indexOf(fileList[i]===-1)){

arr.push(fileList[i])

}

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章