const arrays = [[1,2],[1,2],[2,3],[1,2],[3,4],[1,2]]
const filterArray = array => {
const newArray = [];
array.forEach((currentValue) => {
let isPush = true;
newArray.forEach((currentValueIn) => {
if(currentValueIn) {
if(currentValue[0] === currentValueIn[0] && currentValue[1] === currentValueIn[1]){
isPush = false;
}
}else{
newArray.push(currentValue)
}
})
if(isPush) {
newArray.push(currentValue)
}
})
return newArray;
}
console.log(filterArray(arrays));
网友评论