当前位置:网站首页>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
边栏推荐
- How to use JMeter for interface testing
- Flutter 網絡請求封裝之Dio(Cookie管理、添加攔截器、下載文件、异常處理、取消請求等)
- Which PHP open source works deserve attention
- 2022-2028 global cloud based remote browser isolation industry research and trend analysis report
- oracle -- 表操作
- Unity technical manual - particle emission and life cycle velocity sub module
- 荣耀推出积分商城,支持兑换各种荣耀产品
- ES6-- 集合
- The difference between synchronize and volatile
- Unity技术手册 - GetKey和GetAxis和GetButton
猜你喜欢

2022-2028 global cloud based remote browser isolation industry research and trend analysis report

再突破!阿里云进入Gartner云AI开发者服务挑战者象限

ES6-Const常量与数组解构

2022-2028 global extrusion coating and lamination production line industry research and trend analysis report

How to design a complex business system? From the understanding of domain design, cloud native, micro service, and middle platform

字符串变形(字符串大小写切换和变现)

2022-2028 global vacuum jacket system industry survey and trend analysis report

如何用jmeter做接口测试

2022-2028 global co extrusion production line industry research and trend analysis report

2022-2028 global selective laser sintering service industry research and trend analysis report
随机推荐
Canoe: the fifth simulation project: simulation + test
Unity technical manual - getKey and getaxis and getbutton
2022-2028 global co extrusion production line industry research and trend analysis report
Mysql database index
Data governance is easier said than done
Basic concepts of processor scheduling
记|一次exists关键字的学习记录
2022-2028 global TFT touch screen industry research and trend analysis report
2022-2028 global industrial touch screen industry research and trend analysis report
Unity技术手册 - 生命周期内颜色ColorOverLifetime--速度颜色ColorBySpeed
2022-2028 global horizontal reciprocating compressor industry research and trend analysis report
Huawei cloud SMS has tested that many mobile phones prompt frequent sending
Oracle - 基本入门
2022-2028 global industrial TFT LCD industry survey and trend analysis report
Intimacy - [comfortable exit] - final communication to reduce injury
[invitation letter] on March 4, the platform enabled digital intelligence Innovation -- UFIDA BiP PAAS cloud platform IUAP digital intelligence hundred cities forum · Jinan Station
Jz-064- maximum value of sliding window
Huawei cloud SRE deterministic operation and maintenance special issue (the first issue)
Analysis report on market demand situation and investment direction of China's optical transmission equipment industry from 2022 to 2028
Yyds dry goods inventory CEPH installation visual dashboard