# 代码笔记 **Published by:** [0xb2](https://paragraph.com/@0xb2-2/) **Published on:** 2023-02-23 **URL:** https://paragraph.com/@0xb2-2/Od2ds8ItiR8b5mZRmy0S ## Content //判断数组中对象的值是否有相同的 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(“存在同个值”) } ## Publication Information - [0xb2](https://paragraph.com/@0xb2-2/): Publication homepage - [All Posts](https://paragraph.com/@0xb2-2/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@0xb2-2): Subscribe to updates