如何去掉重复的数组

init () {
    this.filterSameList  = this.XzspKykyApplyDatumReadOnlyObj;
                for (let i = 0; i < this.filterSameList.length; i++) {
                for (let j = i + 1; j < this.filterSameList.length; j++) {
                  if (this.filterSameList[i].DATANAME ===this.filterSameList[j].DATANAME) {
                        this.filterSameList.splice(j, 1);
                    }
                }
            }
            return this.filterSameList;
}

---------------------------------------------------------------------------------------

unique (arr) {
            arr.forEach(item => {
                if (this.filterSameList.indexOf(item.DATANAME) < 0) {
                    this.filterSameList.push(item.DATANAME)
                }
            })
            return this.filterSameList;
        }

filterSameList  代表接受去重复数组后的接收数组       arr 代表要去重的数组

你可能感兴趣的:(JavaScript)