# 代码笔记

By [0xb2](https://paragraph.com/@0xb2-2) · 2023-02-23

---

    //判断数组中对象的值是否有相同的
    
    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(“存在同个值”)
    
    }

---

*Originally published on [0xb2](https://paragraph.com/@0xb2-2/Od2ds8ItiR8b5mZRmy0S)*
