博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
数组对象通过键去重
阅读量:7214 次
发布时间:2019-06-29

本文共 1007 字,大约阅读时间需要 3 分钟。

<!DOCTYPE html>

<html>
<head>
<title>数组去重</title>
</head>
<body>
<script type="text/javascript">
var projectLineLis = [
{value: 1, label: "雪亮标品", $$hashKey: "067"},
{value: 2, label: "大数据", $$hashKey: "068"},
{value: 3, label: "大联动", $$hashKey: "069"},
{value: 4, label: "全科采集", $$hashKey: "06A"},
{value: 5, label: "铁路护路", $$hashKey: "06B"},
{value: 6, label: "平安中国", $$hashKey: "06C"},
{value: 7, label: "社会化服务", $$hashKey: "06D"},
{value: 1, label: "雪亮标品", $$hashKey: "06E"},
{value: 8, label: "12", $$hashKey: "06F"},
{value: 8, label: "45", $$hashKey: "06G"},
{value: 1, label: "雪亮标品", $$hashKey: "06H"},
{value: 2, label: "大数据", $$hashKey: "06I"},
{value: 3, label: "大联动", $$hashKey: "06J"},
]
function arrayUnique2(arr, name) {
var hash = {};
return arr.reduce(function (item, next) {
hash[next[name]] ? '' : hash[next[name]] = true && item.push(next);
return item;
}, []);
}
console.log(arrayUnique2(projectLineLis,'label'))
</script>
</body>
</html>

转载于:https://www.cnblogs.com/xyyyy/p/9965893.html

你可能感兴趣的文章
部署WP程序到自己的手机
查看>>
技术分享:ELK日志分析方案
查看>>
软件开发性能优化经验总结
查看>>
面试题编程题05-python 有一个无序数组,如何获取第K 大的数,说下思路,实现后的时间复杂度?...
查看>>
kendo grid序号显示
查看>>
Spring 教程(二) 体系结构
查看>>
Indexes
查看>>
granfana telegraf influx安装与使用
查看>>
面向对象设计
查看>>
2.Web中使用iReport 整合----------创建html格式的
查看>>
异常备忘:java.lang.UnsupportedClassVersionError: Bad version number in .class file
查看>>
最全三大框架整合(使用映射)——applicationContext.xml里面的配置
查看>>
ecshop商品详情相册顺序调整
查看>>
六、流程控制语句(选择包括switch,迭代语句即循环(搞明白为什么可以循环),跳转(break,continue,goto,return))...
查看>>
mysql中名字为mysql的数据库的user表,可以存储用户信息,以及ip地址等,可以用来重设密码,禁止或允许用户远程访问等...
查看>>
P1446 [HNOI2008]Cards
查看>>
初步理解Java的三大特性——封装、继承和多态
查看>>
知识点积累(一)
查看>>
iphone-common-codes-ccteam源代码 CCFile.m
查看>>
python:浅析python 中__name__ = '__main__' 的作用
查看>>