当前位置:网站首页>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
边栏推荐
- Flutter 網絡請求封裝之Dio(Cookie管理、添加攔截器、下載文件、异常處理、取消請求等)
- Tlog helps Pangu framework realize microservice link log tracking
- zabbix_ Server configuration file details
- .sql数据库导入错误:/*!40101 SET @[email protected]@COLLATION_CONNECTION */
- Reasons why MySQL cannot be connected externally after installing MySQL database on ECs and Solutions
- Talk about adapter mode
- 一位博士在华为的22年
- 2022年中职组网络安全新赛题
- Equivalence class, boundary value, application method and application scenario of scenario method
- 2022-2028 global selective laser sintering service industry research and trend analysis report
猜你喜欢

How to use JMeter for interface testing

Unity的Ping類使用

2022爱分析· IT运维厂商全景报告

As a programmer, how can we learn, grow and progress happily? (personal perception has nothing to do with technology)

Ribbon core ⼼ source code analysis
[email protected]@COLLATION_CONNECTION */"/>.sql数据库导入错误:/*!40101 SET @[email protected]@COLLATION_CONNECTION */

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

Talk about adapter mode

一位博士在华为的22年

2022-2028 global co extrusion production line industry research and trend analysis report
随机推荐
[dynamic programming] longest palindrome substring thinking about dynamic transfer cycle sequence
小程序绘制一个简单的饼图
多模态数据也能进行MAE?伯克利&谷歌提出M3AE,在图像和文本数据上进行MAE!最优掩蔽率可达75%,显著高于BERT的15%...
Flutter 网络请求封装之Dio(Cookie管理、添加拦截器、下载文件、异常处理、取消请求等)
Wpewebkit debugging MSE playback
c语言与数据库的创建使用
27 Chinese scholars including Yaoban and chendanqi from Tsinghua won the awards, and the list of winners of Sloan award in 2022 was issued
zabbix_server配置文件详解
MySQL数据库常用函数和查询
oracle -- 表操作
QT learning setting executable exe attribute (solving the problem of Chinese attribute garbled)
Chapter 3 use of requests Library
22 years of a doctor in Huawei
2022-2028 global open source cloud storage 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
Privatization lightweight continuous integration deployment scheme -- 03 deployment of Web services (Part 2)
2022-2028 global cloud based remote browser isolation industry research and trend analysis report
Hello, teacher, is it really safe to open an account in Alipay fund?
Record the learning record of the exists keyword once
Oracle - 基本入门