js数组对象
有如下数组对象:
let A = [
{ id: 1, name: "张三", address: "北京" },
{ id: 2, name: "李四", address: "上海" },
{ id: 3, name: "张三", address: "杭州" },
{ id: 4, name: "王五", address: "深圳" },
{ id: 5, name: "李四", address: "厦门" },
{ id: 6, name: "张三", address: "广州" },
]
现在希望能根据name属性的值判断是否有重复,如果有就(保存)返回所有name值相同的对象并存入一个新数组中,如果没有重复则删除:如下:
[
{ id: 1, name: "张三", address: "北京" },
{ id: 2, name: "李四", address: "上海" },
{ id: 3, name: "张三", address: "杭州" },
{ id: 5, name: "李四", address: "厦门" },
{ id: 6, name: "张三", address: "广州" },
]
希望各位大佬能帮小弟看下,感谢!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
结果