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])

}

}

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