//普通数组去重
// let arr = [1,2,3,5,1,4,5,2,3,2]
//第一种方法
// let arr2=[...new Set(arr)]
// console.log(arr2)
// console.log(arr2[2])
//第二种方法
// function noRepeat(arr){
// let arr2=[]
// for (let i=0;i<arr.length-1;i++){
// if(arr2.indexOf(arr[i])==-1){
// arr2.push(arr[i])
// }
// }
// return arr2
// }
// console.log(noRepeat(arr))
// console.log(noRepeat(arr)[3])
//对象数组去重
let arrObj = [
{name:"liu1",age:18},
{name:"liu2",age:18},
{name:"liu3",age:15},
{name:"liu3",age:15},
{name:"liu4",age:19},
{name:"liu4",age:20},
{name:"liu4",age:20},
{name:"liu4",age:19},
{name:"liu4",age:19},
{name:"liu5",age:18},
{name:"liu5",age:18},
]
function noRepeatObj(arrObj){
let arr2=[]
let state=true
for (let i=0;i<arrObj.length;i++){
for (let j=0;j<arr2.length;j++){
if(arr2[j].age == arrObj[i].age){
state=false
}
}
if(state){
arr2.push(arrObj[i])
}
state=true
}
return arr2
}
console.log(noRepeatObj(arrObj))