当前位置:网站首页>Array, string de duplication
Array, string de duplication
2022-07-28 13:13:00 【Pig Xiaoyong】
Array weight removal
Method 1 :
Extension operators and Set The combination of structure , You can remove duplicate members of the array .
// Remove duplicate members of the array
[...new Set(array)]
let arr = [3, 5, 2, 2, 5, 5];
let unique = [...new Set(arr)];
// [3, 5, 2]
Method 2 :
Array.from Method can Set Structure to array .
const items = new Set([1, 2, 3, 4, 5]);
const array = Array.from(items);

This provides another way to remove duplicate members of an array .
function dedupe(array) {
return Array.from(new Set(array));
}
dedupe([1, 1, 2, 3]) // [1, 2, 3]
String de duplication
Remove duplicate characters from the string .
[...new Set('ababbc')].join('')
// "abc"
边栏推荐
- [embedded C foundation] Part 1: basic data types
- Kotlin是如何帮助你避免内存泄漏的?
- Jetpack Compose 完全脱离 View 系统了吗?
- Use and source code of livedata in jetpack family bucket
- With 433 remote control UV lamp touch chip-dlt8sa20a-jericho
- 【嵌入式C基础】第9篇:C语言指针的基本用法
- BiliBili Yang Zhou: above efficiency, efficient delivery
- Call / put option price curve
- Which big model is better? Openbmb releases bmlist to give you the answer!
- [matlab]: FFT related problems
猜你喜欢

Machine learning Basics - decision tree-12

01 introduction to pyechars features, version and installation

机器学习基础-集成学习-13

04 pyechars geographic chart (example code + effect diagram)

Science heavyweight: AI design protein has made another breakthrough, and it can design specific functional proteins

Full disclosure! Huawei cloud distributed cloud native technology and Practice

Analysis of Andriod low on memory printing principle

How to open the power saving mode of win11 system computer

How many times can the WordPress user name be changed? Attach the method of changing user name

With 433 remote control UV lamp touch chip-dlt8sa20a-jericho
随机推荐
[pictures and texts] detailed tutorial of one click reinstallation of win11 system
8、 Kubernetes network and load balancing
FutureWarning: Indexing with multiple keys (implicitly converted to a tuple of keys) will be depreca
Aragon创建DAO polygon BSC测试网
05 pyechars basic chart (example code + effect diagram)
Installation and reinstallation of win11 system graphic version tutorial
Definition of option basis
Single option trading and cross trade
面试必问,敲重点!讲一下 Android Application 启动流程及其源码?
A brief introduction to the for loop. Some of the code involves arrays
Machine learning practice - integrated learning-23
Li FuPan: application practice of kata safety container in ant group
UV germicidal lamp chip dlt8p65sa Jericho
Zurich Federal Institute of technology | reference based image super resolution with deformable attention transformer (eccv2022))
[FPGA]: Joint Simulation of FPGA and MATLAB
Change the document type in endnode and import it in word
《TiDB 6.x in Action》发布,凝聚社区集体智慧的 6.x 实践汇总!
Leetcode daily question (2196. create binary tree from descriptions)
Which big model is better? Openbmb releases bmlist to give you the answer!
[embedded C foundation] Part 8: explanation of C language array