代码笔记

//判断数组中对象的值是否有相同的

let arr = [

{id:1,name:2,age:3},

{id:2,name:3:age:24},

{id:1,name:5,age:6}

]

const ids = arr.map(value=>value.id);

const idsSet = new Set(ids);

if(idsSet.size() == ids.length){

console.log(“不存在同个值”)

}else{

console.log(“存在同个值”)

}