当前位置:网站首页>Es6-- set
Es6-- set
2022-06-25 23:03:00 【Climbing procedural ape】
Set
characteristic :
(1) duplicate removal , Added add Delete delete testing has() situation clear Traverse for (let item of set)
Case study 1: Raw data duplicate removal 、 intersection 、 Combine 、 Difference set
// duplicate removal
let arr = [1, 2, 3, 3, 3, 4, 4, 5, 6]
let unique = new Set(arr)
// intersection
let arr2 = [4, 5, 6, 5, 6]
let intersection = [...new Set(arr)].filter(item => {
if (new Set(arr2).has(item)) {
return true
} else {
return false
}
});
// Combine
let union = new Set([...arr, ...arr2])
// Difference set
let diff = [...new Set(arr2)].filter(item => !new Set(arr).has(item))Case study 2: De duplication of object data
let arr = [
{id: 1, name: ' Zhou Yu '},
{id: 3, name: ' Wang Zhaojun '},
{id: 2, name: ' Arthur '},
{id: 1, name: ' Little Joe '},
{id: 2, name: ' Bridge '},
{id: 3, name: ' Han xin '}
];
let obj = {}
arr = arr.reduce((preVal,curVal) => {
obj[curVal.id] ? "" : obj[curVal.id] = preVal.push(curVal)
return preVal
},[])
console.log(arr)Map
characteristic
(1)Map Object has key value pairs , The key can be any data type .
(2)Map Object remembers the original insertion order of keys .
(3)Map Object has an attribute that represents the size of the mapping
边栏推荐
- The wisdom of questioning? How to ask questions?
- ES6学习-- LET
- Why absolute positioning overlaps
- [invitation letter] on March 4, the platform enabled digital intelligence Innovation -- UFIDA BiP PAAS cloud platform IUAP digital intelligence hundred cities forum · Jinan Station
- What are the channels for Internet advertising to gain customers?
- 哪些PHP开源作品值得关注
- 2022-2028 global variable frequency compressor technology industry research and trend analysis report
- 再突破!阿里云进入Gartner云AI开发者服务挑战者象限
- NRM source switching tool
- 2022-2028 global TFT LCD touch screen industry research and trend analysis report
猜你喜欢

2022-2028 global industrial touch screen industry research and trend analysis report

ES6-- 模板字符串、对象的简化写法、箭头函数

Trillions of hot money smashed into the space economy. Is it really a good business?
![Lecture 14 of the Blue Bridge Cup -- number theory [exercises]](/img/96/0971909c8bf25820c2d4f520bb83fb.jpg)
Lecture 14 of the Blue Bridge Cup -- number theory [exercises]

27 Chinese scholars including Yaoban and chendanqi from Tsinghua won the awards, and the list of winners of Sloan award in 2022 was issued

2022-2028 global transmission type photoelectric circuit breaker industry research and trend analysis report

Yyds dry goods inventory CEPH installation visual dashboard

Obsidian basic tutorial

Facing the "industry, University and research" gap in AI talent training, how can shengteng AI enrich the black land of industrial talents?

腾讯《和平精英》新版本将至:新增账号安全保护系统,游戏内违规行为检测升级
随机推荐
Fastjson deserialization randomness failed
Dio encapsulé pour les requêtes réseau flutter (gestion des cookies, ajout d'intercepteurs, téléchargement de fichiers, gestion des exceptions, annulation des requêtes, etc.)
2022-2028 global transmission type photoelectric circuit breaker industry research and trend analysis report
记|一次exists关键字的学习记录
Privatization lightweight continuous integration deployment scheme -- 03 deployment of Web services (Part 2)
Yyds dry goods inventory JD 2, why is redis so fast?
Wpewebkit debugging MSE playback
Hello, teacher, is it really safe to open an account in Alipay fund?
ES6 -- 形参设置初始值、拓展运算符、迭代器、生成函数
APP测试要点
华为云SRE确定性运维专刊(第一期)
2022年河南省第一届职业技能大赛网络安全项目试题
HotSpot JVM 「01」类加载、链接和初始化
Utilisation de la classe Ping d'Unity
Simple and easy-to-use cache library gcache
等价类,边界值,场景法的使用方法和运用场景
Cvpr2022 tutorial | machine learning remote sensing processing: agriculture and food security, University of Maryland
2022-2028 global industrial TFT LCD industry survey and trend analysis report
Fastjson反序列化随机性失败
Nacos 源码分析01 代码结构