js--数组合并并且去重
//二:两个数组合并并且去重 let arr1 = [1, 1, 2, 3, 6, 9, 5, 5, 4]; let arr2 = [1, 2, 5, 4, 9, 7, 7, 8, 8]; //数组组合 let arr12=[...arr1,...arr2];//arr1.push(...arr2); let delsame=[]; let sames=[]; let ss=[]; for(let i=0;i<arr12.length;i++){ if(delsame.indexOf(arr12[i])==-1){ delsame.push(arr12[i]) }else{ //这里是拿出相同的元素 sames.push(arr12[i]) ss=[...new Set(sames)] } } console.log(delsame,sames,ss)