1.双for循环
// that.positions.map(train=>{ // that.new_Positions.push( train.trainId) // }) // that.resultArr = [];//去重后的数组 // var flag; // for (var i in that.new_Positions){ // flag = true; // for (var j in that.resultArr) { // if (that.resultArr[j] == that.new_Positions[i]) { // flag = false; // break; // } // } // if (flag) { // that.resultArr.push(that.new_Positions[i]); // } // } // console.log("that.resultArr:",that.resultArr)
2. ... new set 方法
1 let equipment=[] 2 this.channelsList.map(item=>{ 3 equipment.push(item.equipmentId) 4 }) 5 equipment = [...new Set(equipment)]; 6 console.log("equipment:",equipment) 7 //结果:equipment: (2) ["157680812042523", "157680823318728"]
原文:https://www.cnblogs.com/liweiz/p/12331260.html