当前位置:网站首页>js两个一维数组合并并去除相同项(整理)
js两个一维数组合并并去除相同项(整理)
2022-06-29 17:47:00 【我是开心呀】
//声明两个数组
let arr1 = [1,2,3,4,5,'b'];
let arr2 = ['a',1,'b',5,4];
//先将两个数组合并成一个数组
//使用concat
let cArr = arr2.concat(arr1);
//使用for循环
for(let i = 0; i < arr1.length; i++){
arr2.push(arr1[i]);
}
//然后通过合并后的数组调用Array.from(new Set(参数为数组));
let arr = Array.from(new Set(arr2));
console.log(arr);
边栏推荐
猜你喜欢

最受欢迎的30款开源软件

位图的详细介绍及模拟实现

Issue 42: is it necessary for MySQL to have multiple column partitions
![[webdriver] upload files using AutoIT](/img/69/8c27626d515976b47f1df4831d09c8.png)
[webdriver] upload files using AutoIT

2022春夏系列 KOREANO ESSENTIAL重塑时装生命力

Walk with love, educate and run poor families, and promote public welfare undertakings

How to solve the 2003 error of MySQL in Linux

基于STM32F103ZET6库函数串口实验

人脸识别4-百度商用方案调研

The soft youth under the blessing of devcloud makes education "smart" in the cloud
随机推荐
Timer interrupt experiment based on stm32f103zet6 library function
R语言使用MASS包的glm.nb函数建立负二项广义线性模型(negative binomial)、summary函数获取负二项广义线性模型模型汇总统计信息
人脸识别4-百度商用方案调研
最受欢迎的30款开源软件
Prevent form resubmission based on annotations and interceptors
Bottom level internal skill cultivation
Sword finger offer 13 Robot range of motion (BFS)
Can MySQL views create indexes
Teach you how to install the latest version of mysql8.0 database on windows, nanny level teaching
Graduation season | Huawei experts teach interview tips: how to get a high salary offer from a large factory?
Let's start with a bug that was cheated by the app store
What is a SCM system? What are the advantages of a supply chain management system?
Openfeign use step polling strategy and weight log4j configuration of openfeign interceptor
2022春夏系列 KOREANO ESSENTIAL重塑时装生命力
0 basic self-study STM32 (wildfire) - register lit LED
【Try to Hack】Cookie和Session
填充每个节点的下一个右侧节点指针[利用好每个点->尽可能降低时空复杂度]
mysql. What is the concept of sock
What is the function of MySQL cursors
0 basic self-study STM32 (wildfire) -- use register to light LED -- Explanation of GPIO function block diagram