最简单的js数组去重方法

701 ℃
var county =[
	{name: "鹿城区", value: 8340363, code: "330302"},
	{name: "龙湾区", value: 576804, code: "330303"},
	{name: "瓯海区", value: 14376314, code: "330304"},
	{name: "洞头区", value: 305933, code: "330305"},
	{name: "永嘉县", value: 1034338, code: "330324"},
	{name: "永嘉县", value: 1034338, code: "3303241"},
	{name: "平阳县", value: 1262985, code: "330326"},
	{name: "苍南县", value: 917294, code: "330327"},
	{name: "文成县", value: 211791, code: "330328"},
	{name: "文成县", value: 211791, code: "330328"},
	{name: "泰顺县", value: 230159, code: "330329"},
	{name: "瑞安市", value: 897806, code: "330381"},
	{name: "乐清市", value: 3829048, code: "330382"},
	{name: "龙港市", value: 417067, code: "330383-core"},
	{name: "龙港市", value: 417067, code: "330383"}
]
//去重
const newArr = new Map()
county = county.filter((a) => !newArr.has(a.name) && newArr.set(a.name, 1))
console.log('去重输出', county)

如何利用includes方法对数组去重

js如何利用for语法现实双循环去重

es6语法中如何实现数组去重

es5语法中如何去除数组的重复值

php如何合并数组并去除重复值(重新排序)

标签: 去重, 数组去重

上面是“最简单的js数组去重方法”的全面内容,想了解更多关于 js 内容,请继续关注web建站教程。

当前网址:https://m.ipkd.cn/webs_1553.html

声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

vue简单介绍路由的3大模式
css3语法如何实现动画旋转效果(代码介绍)
Python代码优化之如何避免过度优化
Vue-Router中文文档官网介绍
js如何利用flatMap函数实现数组扁平化