当前位置:网站首页>ES6数组去重 new Set()
ES6数组去重 new Set()
2022-07-25 13:23:00 【刺心疯】
普通数组去重
var b = [...new Set([1,2, 3, 4, 5, 5, 5, 5])]
console.log(b);
包含对象的数组去重
var o ={a:1}
var b = [...new Set([o, o, 3, 4, 5, 5, 5, 5])]
console.log(b);输出结果:

包含对象的数组去重有一个坑,大家需要注意一下:
var b = [...new Set([{'a':1}, {'a':1}, 3, 4, 5, 5, 5, 5])]
console.log(b);因为每个对象都是唯一的,所以这个数组里面的两个对象没办法去重

去除字符串里面的重复字符
[...new Set('ababbc')].join('')
// "abc"边栏推荐
- R语言GLM广义线性模型:逻辑回归、泊松回归拟合小鼠临床试验数据(剂量和反应)示例和自测题
- 面试官问我:Mysql的存储引擎你了解多少?
- 【GCN-CTR】DC-GNN: Decoupled GNN for Improving and Accelerating Large-Scale E-commerce Retrieval WWW22
- Connotation and application of industrial Internet
- 卷积神经网络模型之——VGG-16网络结构与代码实现
- 说说对hashcode和equals方法的理解?
- Azure Devops(十四) 使用Azure的私有Nuget仓库
- Discussion on principle and application technology of MLIR
- mysql函数汇总之日期和时间函数
- VIM basic operation summary
猜你喜欢

Cv2.resize function reports an error: error: (-215:assertion failed) func= 0 in function ‘cv::hal::resize‘

Excel添加按键运行宏

Based on Baiwen imx6ull_ Pro development board transplants LCD multi touch driver (gt911)

程序员成长第二十七篇:如何评估需求优先级?
![[figure attack and Defense] backdoor attacks to graph neural networks (sacmat '21)](/img/d2/6be99fd194c66e4f60af38c6e52c93.png)
[figure attack and Defense] backdoor attacks to graph neural networks (sacmat '21)

好友让我看这段代码

Excel add key run macro

安装mujoco报错:distutils.errors.DistutilsExecError: command ‘gcc‘ failed with exit status 1

Design and principle of thread pool

0715RHCSA
随机推荐
Migrate PaloAlto ha high availability firewall to panorama
0713RHCSA
Friends let me see this code
0719RHCSA
0710RHCSA
Excel添加按键运行宏
How to realize the configuration method of user password free login?
Redis可视化工具RDM安装包分享
Shell common script: get the IP address of the network card
MLIR原理与应用技术杂谈
0716RHCSA
In order to improve efficiency, there are various problems when using parallelstream
Install mujoco and report an error: distutils.errors DistutilsExecError: command ‘gcc‘ failed with exit status 1
Mujoco+spinningup for intensive learning training quick start
并发编程之AQS
IM系统-消息流化一些常见问题
Docker learning - redis cluster -3 master and 3 slave - capacity expansion - capacity reduction building
Connotation and application of industrial Internet
Pytorch creates its own dataset and loads the dataset
[figure attack and Defense] backdoor attacks to graph neural networks (sacmat '21)