当前位置:网站首页>数组去重-基本数据类型
数组去重-基本数据类型
2022-04-22 22:13:00 【厚渡】
将如下数组去重
let arr = [3, 1, 2, 3, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, '1', '2', '3', 77, 9];
// 使用循环 函数 流程控制 等手段
// 去重
function qc(arr) {
let o = [];
for (let i = 0; i < arr.length; i++) {
const element = arr[i];
if (!o.includes(element)) {
o.push(element);
}
}
return o;
}
console.log(qc(arr));
版权声明
本文为[厚渡]所创,转载请带上原文链接,感谢
https://blog.csdn.net/dwp_wz/article/details/124322188
边栏推荐
猜你喜欢

51单片机proteus仿真 按键控制数码管数字显示

小赛毛游C记——初识C语言(3)

【4.1】flink窗口算子的trigger触发器和Evictor清理器

初学单片机点亮第一个外设--LED灯

396. 旋转函数 / 剑指 Offer II 013. 二维子矩阵的和

2.58-编写程序is-little-endian,当在小端法机器上编译和运行时返回1,在大端法机器上编译和运行时则返回0。这个程序应该可以运行在任何机器上,无论机器的字长是多少。

MySql内置函数
![[wechat applet development (cloud wallpaper applet tutorial)]](/img/71/d1ec9b0e7af47427c1e19b9b949bfa.png)
[wechat applet development (cloud wallpaper applet tutorial)]

多线程进阶(八)----线程池

MySql--- 数据类型
随机推荐
What is the magic of moonbirds NFT, which became popular overnight?
Come to a Vue boss and see if there is an iframe cache scheme?
条件编译分析及使用
MySql--数据库基础
Graph and numerical representation of knowledge map of knowledge representation
GBase 8s V8.8 SQL 指南:教程-6.2.1(3)
[mmub] mobile phone user behavior modeling based on Hidden Markov Model -- hidden Markov model
【深入浅出强化学习】1 绪论
2.55-在你能够访问的不同机器上,使用show_bytes(文件show_bytes.c)编译并运行示例代码。确定这些机器使用的字节顺序。
对话杨炯纬,快体现在抓住“红利”上,实际上TO B公司应该跑得慢一点
JVM性能调优1
GBase 8s V8. 8 SQL Guide: Tutorial - 6.1.2 (3)
GBase 8s V8.8 SQL 指南:教程-6.2.1(2)
GBase 8s V8. 8 SQL Guide: Tutorial - 6.2.1 (4)
Catering industry cashier system source code, C # Net + MSSQL WPF
小赛毛游C记——初识C语言(3)
hawe哈威液压泵站的液压冲击分析
Realizing tab switching with foreach and ES6
PHP wechat refund certificate
动态规划:分组背包问题